cancel
Showing results for 
Search instead for 
Did you mean: 

AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

SOLVED

AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

Hi,

 

AOE Scheduler's instructions tell me to add the two following configurations to my crontab:

 

*/5 * * * * ! test -e /home/tozdoojd/public_html/maintenance.flag && /bin/bash /home/tozdoojd/public_html/scheduler_cron.sh --mode always
*/5 * * * * ! test -e /home/tozdoojd/public_html/maintenance.flag && /bin/bash /home/tozdoojd/public_html/scheduler_cron.sh --mode default

 

When I run these commands through SSH using Putty, they work fine. But when scheduled in Cpanel's crontab, they don't.

My hosting company said the jobs are being executed as scheduled, as they showed me in this log:

[root@nexundbr001 ~]# grep "/home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh" /var/log/cron
Sep 29 11:30:02 nexundbr001 CROND[20153]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 11:30:02 nexundbr001 CROND[20152]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:35:01 nexundbr001 CROND[28638]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 11:35:01 nexundbr001 CROND[28674]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:40:01 nexundbr001 CROND[5048]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:40:01 nexundbr001 CROND[5074]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 11:45:01 nexundbr001 CROND[13189]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 11:45:01 nexundbr001 CROND[13203]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:50:01 nexundbr001 CROND[20609]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:50:01 nexundbr001 CROND[20629]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 11:55:02 nexundbr001 CROND[27618]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 11:55:02 nexundbr001 CROND[27648]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:00:02 nexundbr001 CROND[1898]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:00:02 nexundbr001 CROND[1910]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:05:01 nexundbr001 CROND[8847]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:05:01 nexundbr001 CROND[8848]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:10:01 nexundbr001 CROND[15944]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:10:01 nexundbr001 CROND[15945]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:15:01 nexundbr001 CROND[22791]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:15:01 nexundbr001 CROND[22879]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:20:01 nexundbr001 CROND[29555]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:20:01 nexundbr001 CROND[29638]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:25:02 nexundbr001 CROND[4007]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:25:02 nexundbr001 CROND[4093]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:30:02 nexundbr001 CROND[13708]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:30:02 nexundbr001 CROND[13714]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:35:02 nexundbr001 CROND[20727]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:35:02 nexundbr001 CROND[20778]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:40:01 nexundbr001 CROND[27539]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:40:01 nexundbr001 CROND[27734]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:45:02 nexundbr001 CROND[2075]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:45:02 nexundbr001 CROND[2202]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:50:01 nexundbr001 CROND[8840]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 12:50:01 nexundbr001 CROND[8953]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:55:02 nexundbr001 CROND[15638]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 12:55:02 nexundbr001 CROND[15811]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:00:02 nexundbr001 CROND[22592]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:00:02 nexundbr001 CROND[22590]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:05:01 nexundbr001 CROND[29297]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:05:01 nexundbr001 CROND[29313]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:10:02 nexundbr001 CROND[3713]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:10:02 nexundbr001 CROND[3736]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:15:01 nexundbr001 CROND[10613]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:15:01 nexundbr001 CROND[10718]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:20:01 nexundbr001 CROND[17253]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:20:01 nexundbr001 CROND[17387]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:25:01 nexundbr001 CROND[24393]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:25:01 nexundbr001 CROND[24406]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:30:01 nexundbr001 CROND[31194]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:30:01 nexundbr001 CROND[31196]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:35:01 nexundbr001 CROND[5638]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:35:01 nexundbr001 CROND[5766]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:40:01 nexundbr001 CROND[16847]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:40:01 nexundbr001 CROND[16934]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:45:01 nexundbr001 CROND[24193]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:45:01 nexundbr001 CROND[24259]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)
Sep 29 13:50:02 nexundbr001 CROND[3042]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode always)
Sep 29 13:50:02 nexundbr001 CROND[3050]: (my-cpanel-login) CMD (! test -e /home/my-cpanel-login/public_html/maintenance.flag && /bin/bash /home/my-cpanel-login/public_html/scheduler_cron.sh --mode default)

I already tried adding the following line of code in my cron.php file:

isShellDisabled = true;

My AOE Scheduler's timeline view is:

Cron jobs not working from cpanelYou can see in green the jobs ran from command line.

 

Could the problem be with my hosting company, or maybe the command should be different in Cpanel than it is in command line? Or the problem is something else? It would be a great help if someone could point me to the right direction.

 

I'm using Magento CE 1.9.3.4 and AOE Scheluder is up to date.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

cfarnleitner, first of all, thank you very much for your reply.

 

I don't know much about Linux servers, so I couldn't figure out some parts of your explanation. However, the path was indeed my problem.

 

My crontab runs with root user, and for that reason the command line environment was differente from crontab's.

 

To solve the problem I ran the command "set" from command line, and copied the PATH variable. Then I added this PATH to my scheduler_cron.sh file, right after #!/bin/bash. And now the crontab works!

 

Thank you very much.

View solution in original post

4 REPLIES 4

Re: AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

Hey

 

Just a quick though:

When you run 

php -v

on cli, does it reply with a PHP version of 5.x (Magento 1.x is not compatible with PHP7 out of the box)?

Re: AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

Thanks for the reply, cfarnleitner

PHP version is 5.6.31. This is what I got from php -v:
 
 
 
php -v command result

Re: AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

Hey Raphael!

 

That one seems a bit tricky but I think I got some hints that might help you to get on track to figure out what the actual issue is:

one possible reason can be that "/home/my-cpanel-login/public_html/" isn't actually the correct path even though AOE things it is. In a shared hosting environment this might be the case when your ssh user is jailed within your users webspace. Now, when the server runs the cron which not always is done on behalf of the webuser itself but of one more global one (root in worst case) then especially for a shared webhost a path such as /home/my-cpanel-login/public_html as actual webroot seems quite odd to me since a path starting with a slash is meant to be an absolute path.

So, one possible solution could be that your actual path is ./home/my-cpanel-login/public_html/ (path starting with a dot followed by a slash which makes it relative) - however it then still depends on from within where the cron is executed.

Another possibility could be that the user that runs the cron is having a different php version set.

 

Some commands that might help you to figure out where you are when the cron runs can be:

pwd

which given you the current path

ls -l

which gives you the current directories content

and again

php -v

Usually you should be able to execute these command in the very same way as a cron job as you would run them directly from cli.

Appending 

> output.txt

 would write the output of the executed command into the file output.txt. In fact, if there is no error i.e. about a permission restriction which should give you a clear path already and you still can NOT find this file at your root then the cron most likely is not executed properly (accessing a wrong path).

 

An alternative solution - in case that is not the issue - is that you would still be able to execute Magento's default cron.php together with AOE (even though that wouldn't make too much sense since anyway cron.sh should be preferred where ever possible it should still work)

 

 

Re: AOE Scheduler - Jobs run from command line, but doesn't from Cpanel's crontab

cfarnleitner, first of all, thank you very much for your reply.

 

I don't know much about Linux servers, so I couldn't figure out some parts of your explanation. However, the path was indeed my problem.

 

My crontab runs with root user, and for that reason the command line environment was differente from crontab's.

 

To solve the problem I ran the command "set" from command line, and copied the PATH variable. Then I added this PATH to my scheduler_cron.sh file, right after #!/bin/bash. And now the crontab works!

 

Thank you very much.