2

I have inherited a magento site owned by a customer and we are getting errors logged in var/reports every 5 minutes, I have checked our cron job setup with host and it appears to be in the correct SimpleTrigger format. I've been researching the issue but I don't really understand how it works so I'm hoping someone can help point me in the right direction. Thanks, J

a:4:{i:0;s:45:"Invalid cron expression: 0 5 10 15 20 * * * *";i:1;s:1238:"
#0 /chroot/home/domain/domain.com/html/app/code/core/Mage/Cron/Model/Schedule.php(68): Mage::exception('Mage_Cron', 'Invalid cron ex...')
#1 /chroot/home/domain/domain.com/html/app/code/core/Mage/Cron/Model/Observer.php(214): Mage_Cron_Model_Schedule->setCronExpr('0 5 10 15 20 * ...')
#2 /chroot/home/domain/domain.com/html/app/code/core/Mage/Cron/Model/Observer.php(168): Mage_Cron_Model_Observer->_generateJobs(Object(Mage_Core_Model_Config_Element), Array)
#3 /chroot/home/domain/domain.com/html/app/code/core/Mage/Cron/Model/Observer.php(128): Mage_Cron_Model_Observer->generate()
#4 /chroot/home/domain/domain.com/html/app/code/core/Mage/Core/Model/App.php(1338): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer))
#5 /chroot/home/domain/domain.com/html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Cron_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
#6 /chroot/home/domain/domain.com/html/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('default', Array)
#7 /chroot/home/domain/domain.com/html/cron.php(46): Mage::dispatchEvent('default')
#8 {main}";s:11:"script_name";s:57:"/chroot/home/domain/domain.com/html/index.php";s:4:"skin";s:5:"admin";}
2

Welcome to Magento.SE!

The cron expression you're looking for is not set up in your host, rather, it's configured in a Magento module.

The problem

The module you're installed has attempted to make the cron run every 5 minutes for the first 20 minutes of every hour of every day. However, this is improperly formatted.

It should instead look like this:

0,5,10,15,20 * * * * 

Fixing the error

You are going to have to find the code that is failing. If you've recently installed a module since the error started that would be a great place to look.

This declaration is likely in the etc/config.xml file of a 3rd party module. You can begin looking for these in app/code/local and also in app/code/community.

Here's a command-line script you can run to find the offending file:

grep "0 5 15" ./app/code/{community,local} -R
1

The crontab notation in your snippet is actually incorrect. Crontab notation has room for 5 inputs.

* * * * * /path/to/some/executable

In your snippet you've got

0 5 10 15 20 * * * *

So essentially cron is reading that as having 9 inputs instead of 5. Now I'm a little fuzzy on what exactly you're trying to do, but if you're trying to run the cronjob on the 0, 5, 10, 15, 20 minute (i.e. 12:00, 12:05, 12:10, 12:15, 12:20), then your crontab notation would actually need to be

0,5,10,15,20 * * * *

If you're trying to run the cronjob every 5 minutes and just didn't want to put the full expression, then you could go with

*/5 * * * *

or

0,5,10,15,20,25,30,35,40,45,50,55 * * * * 

Crontab notation is definitely a little weird at first. Here's a good write-up that explains the different fields, how to work with them, and has examples too. http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

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.