I'm really struggling with the below cron job and any help would be appreciated. I'm running Magento and I'm trying to run cron.php every minute through a cron job. I now understand that you should use cron.sh which I've also tested below.

I can log into SSH and run any of the following commands and they all work as they should, forgot password emails sent / new products created from an import etc:

/usr/bin/sh /home/thefootb/public_html/cron.sh cron.php --mode=always
/usr/bin/sh /home/thefootb/public_html/cron.sh cron.php --mode=default
/usr/bin/php /home/thefootb/public_html/cron.php

But when I but these into a cron job (logging into SSH and using crontab -e) nothing happens. Here's my crontab file:

* * * * * /usr/bin/sh /home/thefootb/public_html/cron.sh cron.php --mode=always
* * * * * /usr/bin/sh /home/thefootb/public_html/cron.sh cron.php --mode=default
* * * * * /usr/bin/php /home/thefootb/public_html/cron.php

I've also tried:

* * * * * /usr/local/bin/php /home/thefootb/public_html/cron.php

As I this is what my host advised me.

I'm really stuck with this - it should be so simple but it just won't work.

Thanks in advance Chris

  • Might be the issue with PATH variable. Can you try it by adding PATH variable in your cron.php and execute it?
    – Bhavani
    Aug 18 '17 at 17:27

If you have multiple versions of PHP installed you need to specify which version you want manually. The version of PHP the is used for web visitors is not necessarily the same version that is used for CLI or cron. Here's how you could do cron with the explicit PHP version specified (replace /opt/remi/php70/root/usr/bin with your particular path):

    /opt/remi/php70/root/usr/bin/php -c /home/thefootb/public_html/cron.php

FYI: php -c specifies look for php.ini in this particular directory. See docs.

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.