2

I tried these two commands from SSH. They worked.

/bin/sh /path/to/magento/cron.sh
/usr/bin/php /path/to/magento/cron.php

I put exactly the same commands (either one) on cPanel Cron Job. The commands were executed, but nothing happened. What might be wrong here?

Curl command works, but i'm trying to make cron.php not accessible from outside.

5
  • 1
    is there any error in /var/spool/mail/{CPANELUSER} ? or add MAILTO="YOUR_MAIL_ADDRESS" on top of your crontab file
    – MagenX
    Commented Nov 5, 2015 at 22:28
  • I set it up so that cPanel sends output to my mailbox every time the cron job runs. No errors.
    – Shawn
    Commented Nov 5, 2015 at 23:25
  • How does your crontab look after you have configured it in Cpanel? crontab -e
    – Erfan
    Commented Nov 6, 2015 at 5:59
  • Running "crontab -e" I got "/bin/sh: pico: command not found /usr/bin/crontab.cagefs: "pico" exited with status 127." Now I found out if I add options to the end, the cron job works! When running in SSH, I don't have to add options. Any idea why? Here are new cron commands: */5 * * * * /usr/local/bin/php /home/frcb/public_html/cron.php -mdefault */5 * * * * /usr/local/bin/php /home/frcb/public_html/cron.php -malways
    – Shawn
    Commented Nov 6, 2015 at 17:49
  • @Shawn What do you mean by nothing happening and but i'm trying to make cron.php not accessible from outside. Can you explain bit more?
    – Mukesh
    Commented Feb 15, 2016 at 14:41

4 Answers 4

2

You cron should look like the following path:-

By SSH Server use this,

*/5 * * * * /bin/curl --silent -H "Host: abc.com" http://localhost/cron.php > /dev/null 2>&1

Note:- Here, the first part " */5 * * * * " and " 10 * * * * " are the CRON schedule times.

OR

10 * * * * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1 

The command itself in this example has three parts:

  1. "/usr/bin/php". PHP scripts usually are not executable by themselves. Therefore we need to run it through the PHP parser.
  2. "/www/virtual/username/cron.php". This is just the path to the script.
  3. "> /dev/null 2>&1". This part is handling the output of the script. More on this later.
0

You cron should look like the following

* * * * * /bin/sh /path/to/your/site.com/html/cron.sh &> /dev/null
2
  • Yes that's what I have on cPanel Cron Job. Not working.
    – Shawn
    Commented Nov 5, 2015 at 23:22
  • What does your hosting provider say? What is "Not" working? Commented Nov 6, 2015 at 12:26
0

Please run cron.php using http://www.example.com/cron.php and check table cron_schedule in database and you could able to see new entries.

Then update command - /bin/sh /path/to/your/site/public_html/cron.sh >/dev/null 2>&1

And check table cron_schedule in database and you could able to see new entries.

0

Normally. If you run

/usr/bin/php /path/to/magento/cron.php

First: with no parameter. Cron.php will call:

  • cron.sh -mdefault 1 > /dev/null 2>&1 &
  • cron.sh -malways 1 > /dev/null 2>&1 &

As you tell: /bin/sh: pico: command not found /usr/bin/crontab.cagefs That is the reason it do nothing. I mean because sh shell have error it self.

Second: With parameter: cron.php -mdefault or cron.php -malways. The call immediate executed at php side do not call cron.sh. So it is perfect fine in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.