Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Cron Tab Job Time zone

Im trying to figure out if my module cron is running at the correct time.

The cron for my module is set at 1am (0 1 * * *), the time zone of the default store is Western Europe (Paris, Berlin etc GMT +2), the server time is EDT (Eastern Daylight Time).

So on which time zone is the 1am schedule based on?

Thanks,

like image 960
Jono Avatar asked Sep 28 '11 08:09

Jono


2 Answers

The Magento cron process runs under the UTC timezone.

This can be verified by temporarily adding a small log statement to the cron observer.

The method is:

Mage_Cron_Model_Observer::dispatch()

Look for this code in the first few lines:

$now = time();

Either right before or after, add this:

Mage::log("cron timezone: " . date_default_timezone_get(), Zend_Log::DEBUG);

Then check your var/log/system.log file and you will see that PHP/Magento is using the UTC timezone.

like image 98
Lee Saferite Avatar answered Sep 20 '22 06:09

Lee Saferite


The Magento cron job log times are recorded in UTC. Actual run times are based off the TZ offset (server time). Here's a Cron Job Monitor script that shows you the jobs as they're scheduled and then their completion times. It also gives you UTC, the server time and your store time (single store). All three can be different. Cron Job Monitor

For it to be useful, I set System Config to keep errors and logged information for 24 hours. That way you can actually monitor the big jobs that run in the early AM and confirm they're really running.

like image 45
Fiasco Labs Avatar answered Sep 19 '22 06:09

Fiasco Labs