3

I am having issues with cron.php constantly running. I never had an issue with this until I upgraded to Magento CE 1.9.1.1. My hosting provider actually had to disable cron.php because it was causing a high load on the CPU. I installed AOE Scheduler and disabled some tasks which weren't necessary. I then had my hosting provider re-enable access to cron.php. However, cron will not run on the server even though I have a cron job setup correctly. I then decided to manually run the cron job by entering it's address in my internet browser's address bar. Once again, cron.php would constantly run and not stop, causing a high load on the CPU. The only way I could get it to stop was to rename cron.php to something like cron.BAK.

Cron tasks do run when I use AOE Scheduler to run the task immediately. However, I can create a schedule with AOE Scheduler and cron isn't running those tasks because it still isn't being executed by the server.

My question is two fold...

  1. How do I find out why cron.php won't stop running? Is this an issue with 1.9.1.1? I never had this issue until I upgraded from 1.9.1.0 to 1.9.1.1.

  2. Why isn't the server executing the cron job I have setup? Once again, I never had this issue until I upgraded to 1.9.1.1.

Right now, I'm mainly concerned with question #1. Question #2 is a low priority until I can get cron.php to run the tasks it's supposed to run and then stop. It's becoming a real pain because I'm getting hounded by my hosting provider about the high CPU load.

  • This is what is showing in my system.log over and over again until I rename cron.php to stop it from running... 2015-05-27T16:00:47+00:00 ERR (3): Warning: shell_exec() [<a href='function.shell-exec'>function.shell-exec</a>]: Unable to execute '/bin/sh /home/lbingman/public_html/cron.sh cron.php -mdefault 1 &gt; /dev/null 2&gt;&amp;1 &amp;' in /home/lbingman/public_html/cron.php on line 64 – Lucas May 27 '15 at 16:21
  • And... 2015-05-27T16:00:47+00:00 ERR (3): Warning: shell_exec() [<a href='function.shell-exec'>function.shell-exec</a>]: Unable to execute '/bin/sh /home/lbingman/public_html/cron.sh cron.php -malways 1 &gt; /dev/null 2&gt;&amp;1 &amp;' in /home/lbingman/public_html/cron.php on line 65 – Lucas May 27 '15 at 16:22
  • Lines 64 and 65 of cron.php show this... 64 - shell_exec("/bin/sh $baseDir/cron.sh $fileName -mdefault 1 > /dev/null 2>&1 &"); 65 - shell_exec("/bin/sh $baseDir/cron.sh $fileName -malways 1 > /dev/null 2>&1 &"); – Lucas May 27 '15 at 16:22
3

You should not call/run cron.php directly but cron.sh via system cronjob/crontab instead.

I can recommend Fabrizios Blogpost for more information about the Magento cron:

cron.php vs. cron.sh

In Magento’s root folder there’s a cron.php file and a cron.sh file. Briefly explained cron.sh internally calls cron.php and takes care of not executing more than one process in parallel. That’s a good thing, right? Well, sometimes… If you have long running tasks (e.g. a product import implemented as a task), these tasks will prevent anything else from being executed until the task has finished. You might have some other important tasks that shouldn’t wait or be skipped just because another task is running. Check the “Missed if Not Run Within” setting to configure the maximum delay a task can have to still be executed.

On the other hand using cron.php will start a new process every time it’s being called which could easily result in performance problems or race conditions for tasks operating on the same data. This is why cron.php should not be called directly. Find out more about cron groups later in this blog post for a nice solution on how to handle this situation.

http://www.webguys.de/magento/tuerchen-08-magento-cron-demystified/

  • Maybe I'm missing something, but this still doesn't answer my question. I have AOE Scheduler installed and have cleared all of the tasks. Even with nothing scheduled, cron.php just runs and runs. It's like it says I have nothing scheduled, yet there's things running per cron that I can't see. – Lucas May 27 '15 at 16:09
2

you need to kill cron, and restart it as in crontab, then install mytop https://launchpad.net/ubuntu/+source/mytop/1.9.1-1, to see if there is anything stuck in database, also you need to strace (http://linux.die.net/man/1/strace , http://chadfowler.com/blog/2014/01/26/the-magic-of-strace/ ) cron pid. had this issue before and after we found that cron is trying to run one job too long we used

Cron groups: Split you crons into different groups so you can run them in parallel or distribute them on multiple servers.

and now everything is good.

  • I just looked in the cron_schedule table and found it was empty, yet it is still running and causing 85% CPU usage. Any other ideas? – Lucas May 29 '15 at 16:54

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.