How to set cron job in cpanel
Solution 1
Here are some of my tries :)
The following worked fine in my case:
wget -O /dev/null http://example.com/cron/my-cron.php >/dev/null
Also the following worked fine (I think this is better if we have 'https://' in the URL):
/usr/bin/php -q /home/user/public_html/cron/my-cron.php >/dev/null
Another one:
curl -s http://example.com/cron/my-cron.php >/dev/null 2>&1
If you do not wish to receive an email notifying you of a specific cron job, add the following line to the command: >/dev/null 2>&1
Ref: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/CronJobs
Solution 2
I'm using this:
/usr/bin/wget -q -O /dev/null "http://www.mydomain.com/myscript.php" > /dev/null 2>&1
Mohan Ram
H.R. Mohan Ram, Software Engineer III, Bank of America Email: [email protected] Mobile: (+91)9578352644 / (+91)8806199976
Updated on June 04, 2022Comments
-
Mohan Ram almost 2 years
I am using X10 hosting
Server is https://boru.x10hosting.com
In add cron job i had given
Command
/usr/bin/php -q /home/mohanphp/www/quote_bot/sms_cron.php >>/home/mohanphp/www/quote_bot/log/cron_log.txt 2>&1
I had tried
/usr/bin/php -q /home/mohanphp/www/quote_bot/sms_cron.php >/dev/null 2>&1 /usr/bin/php -f /home/mohanphp/www/quote_bot/sms_cron.php >/dev/null 2>&1
I had set cron for every 5 minutes.
Please help me what wrong i did with the command.
-
DCoder about 12 yearsDid you check the error logs? Remove the
>/dev/null
part for a while so you can see the generated output (you will receive it via email). -
Mohan Ram about 12 yearserror log is empty and i didnt received mail also
-
Ondrej Peterka about 12 yearsSome hostings have restrictions on how often a cron job can be run (e.g. only every 15 minutes as the "most often"). You should check the docs of your hosting. Also you can try to put your php command in shell script (with redirecting output etc.) and than run this shell script from cron job. It might be easier to debug.
-