Cron job is not working properly in cpanel

Manoj picture Manoj · Oct 23, 2012 · Viewed 10.7k times · Source

I have setup cron job, it is working properly, however when i directly runs the php file(from the path/url) it successfully runs, but from cron its not. However i set another very simple file to make sure my cron command/path is set correctly i created another file and used simple php mail function and its is running successfully. Kindly suggest me the possible areas to look into it. (I am using Cpanel)

Answer

alan978 picture alan978 · Nov 1, 2012

Instead of putting in cronjob command like

php -f /path_to_script/script.php 

put command like this:

curl http://domain.com/yourscript.php

if you want to suppress output you can add > /dev/null at the end.

So full command would be:

curl http://domain.com/yourscript.php > /dev/null

Hope this helps!