7

I am having big issues with the cron of Magento 1.9.1 hoping someone can help. I have AOE installed and see not heartbeat.

I have added my cron job

*/5 * * * * /bin/sh /var/sites/p/domain/public_html/cron.sh

But this still does not run, so I decided to try and try and run cron.php, this does nothing. This is my cron for this

*/5 * * * */usr/bin/wget -O /dev/null -o /dev/null http://www.domain.com/cron.php

Based on Magneto 1.8 cron.php I added the following to the cron.php.

$isShellDisabled = true;

Based on this still not working I tried the cron.php in the browser. I get an error in the browser that Printing is disabled by default for security reasons.

So I changed my php.ini to memory_limit = 512M just incase. This is still not working.

The error I get in my reports for this is:

 a:5:{i:0;s:59:"Mage registry key "_singleton/cron/observer" already exists";i:1;s:537:"#0 /var/sites/p/domain.co.uk/public_html/app/Mage.php(223): Mage::throwException('Mage registry k...')
#1 /var/sites/p/domain.co.uk/public_html/app/Mage.php(477): Mage::register('_singleton/cron...', false)
#2 /var/sites/p/domain.co.uk/public_html/app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('cron/observer')
#3 /var/sites/p/domain.co.uk/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#4 /var/sites/p/domain.co.uk/public_html/cron.php(74): Mage::dispatchEvent('default')
#5 {main}";s:3:"url";s:9:"/cron.php";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}

Any help would be really great.

Note ** I have change the domain name to DOMAIN due to my site not being suitable for work.

Vinnie
  • 71
  • 1
  • 1
  • 2
  • When you go to AOE's list view (System >> Scheduler >> List View), do you see any jobs listed? If not, click the 'Generate Schedule' button at the top. Do you see jobs listed now? – Jory Geerts Apr 20 '15 at 13:23
  • There might be some suggestions in here that might help: http://stackoverflow.com/questions/25177502/magento-cron-job/25183755 – PedroKTFC Apr 20 '15 at 13:24
  • 1
    Are crons running at all on the server ? What's happening when you launch php cron.php at the root of the magento's folder ? – Christophe Ferreboeuf Apr 20 '15 at 14:01

3 Answers3

18

Few simple steps to fix Magento cron issue:

  1. Go to System > Configuration > Advanced > System > Cron (Scheduled Tasks) and set next values:

    • Generate Schedules Every: 15
    • Schedule Ahead for: 20
    • Missed if Not Run Within: 15
    • History Cleanup Every: 10
    • Success History Lifetime: 60
    • Failure History Lifetime: 600
  2. Clear Cache in System > Cache Management

  3. Clear 'cron_schedule' table. You can do it via phpmyadmin or execute next command in SQL console:

    TRUNCATE TABLE cron_schedule;

  4. Add next line to cron settings (use absolute paths):

    */5 * * * * /usr/bin/php /absolute/path/on/your/server/to/file/cron.php

Note: in some configurations on webserver (apache/nginx) allowed to execute php scripts. In this case add this line to webserver's user crontab. Example for apache: crontab -u apache -e

  1. Restart cron daemon.

  2. Check table 'cron_schedule', if it's not empty - Magento cron script start working.

ToxaBes
  • 1,587
  • 8
  • 17
  • where to write "*/5 * * * * /usr/bin/php /var/sites/p/domain/public_html/cron.php" – Wasiq Shahrukh Sep 18 '17 at 07:23
  • It depends of your system. In Linux OS in most common case type "crontab -e" and add this line. – ToxaBes Sep 20 '17 at 15:50
  • This didn't exactly work for me, But it was close: Follow Steps 1 2 3 4 Then step 5 should be: */5 * * * * apache /var/www/dev/company_dev/cron.sh Then step 5 and 6 is fine. The cron.sh script calls the php file and Apache is the only user who has permissions to alter and run scripts in Magento. Thus the change in executor. – dustbuster Oct 23 '18 at 14:51
  • @dustbuster - here is thousand ways for setup web server, I provide working instruction for topic starter's variant. In your case if apache have access to cron (pam settings) you can do step 4 via command: crontab -u apache -e – ToxaBes Oct 24 '18 at 10:12
  • Absolutely. I wasn't suggesting there was anything wrong with your answer. Just wanted to provide some additional info in case someone runs into the same issues I did! – dustbuster Oct 24 '18 at 13:52
  • How to restart cron deamon?! – Black Feb 14 '19 at 16:28
9

Well I've had a different issue. My cron was simply not working, although cron.php was executed properly. Still no output, and no jobs done.

I've checked cron_schedule and noticed that last job there is from 19th of March this year (sic!). So i kept on looking for cause.

Finally I've noticed that that there is process running with my cronjob from 19th of March (sic!).

josh 21350 99.6 0.4 350400 133492 ? R Mar19 241812:21 /usr/bin/php /var/www/mysite/cron.php -mdefault

I've killed the job with: kill -9 21350

And voila! Suddenly newsletter is being sent!

I had no idea why, and how this happened. Now i know i should pay attention to it, so I will.

Deus777
  • 1,816
  • 1
  • 20
  • 18
1

I just saw that you are using magento 1.9.1.

Run the cron using php instead : /usr/local/bin/php -f /home/cpanel_username/public_html/cron.php

This should resolve http permission problems you might be having when using 'usr/bin/wget -O /dev/null -o /dev/null'

Try that command and let me know if it works for you.

Maur
  • 31
  • 2