4

I have a cron job set up to run the cron.sh file every 5 minutes, as per the installation guide. I have checked the server's cron log history and it is correctly running the job on schedule.

I added file_put_contents('cronlog.txt', date('c') . "\n", FILE_APPEND); to the end of the try block in cron.php to verify, but it's logging two identical dates every 5 minutes, like cron.php is calling itself recursively.

Is this normal behaviour? If not, any ideas as to what could cause such strangeness?

3

On newer versions this is expected. If you take a look at cron.php this part would get executed:

        shell_exec("/bin/sh $baseDir/cron.sh $fileName -mdefault 1 > /dev/null 2>&1 &");
        shell_exec("/bin/sh $baseDir/cron.sh $fileName -malways 1 > /dev/null 2>&1 &");

which then loops through cron.sh to call the cron.php again two times. It gets executed once in always mode and another time as default

    Mage::dispatchEvent($cronMode);

Further reading http://davidalger.com/development/magento/a-new-breed-of-cron-in-magento-ee-1-13-2/

| improve this answer | |
0

You may get Magento cron jobs running multiple times depending on how cron is configured on the server compared to in Magento. Say for instance you have a Magento cron job scheduled to run every 5 minutes, but the server is only polling cron.php/cron.sh every 10 minutes, assuming jobs are being scheduled ahead and are not considered missed by 10 minutes then you will get that job running twice every time 10 minutes as it will run the job for then, but also 5 minutes previously which was missed as the server did not poll Magento's cron at that time.

Check you have the server cron configured to run at least as regularly as the most regular Magento cron job you want to run. It sounds like every 5 minutes is good for you (which is pretty common).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.