From Hostek.com Wiki
cPanel/Linux - Setting up Cron Jobs
- Please keep in mind that you may require a specific service for a cron job to get properly executed. For example, a PHP request requires /usr/bin/php to run-- like the cron below:
/usr/bin/php -q /home/user/public_html/cron.php
- If you do not want email confirmation for each successful cron, you will need to add the following to the end of your cron job:
/usr/bin/php -q /home/user/public_html/cron.php > /dev/null
- If you want to use a HTTP URL in your cron, it would look like the following.
/usr/bin/curl --silent --output /dev/null http://yourdomain.com/cron.php
- If your HTTP URL cron has special characters such as '&' or ':' in the URL, you can include those normally, as below. Note that using URL encoding like %26 and %3a will not work with curl.
/usr/bin/curl --silent --output /dev/null http://yourdomain.com/cron.php:example&example=example
WCP/Windows - Setting up Cron Jobs
- With a recent update to Windows Control Panel (WCP) we've added Windows cron jobs. To make use of these, login to WCP and find the Cron Jobs tool (clock icon). It'll be on the bottom of the panel. To set up a cron on Windows:
- Click Add
- Choose a name for the Cron
- Place a URL to be executed
- If this is a simple cron, keep the Easy mode selected. Advanced gives you complete control over when your cron runs.
- Choose the interval at which the cron runs
- Click Save
Common Cron Failures
- Not Firing: When You Specified Make sure your time format is correct. Sometimes extra zeroes or an extra asterisk (*) makes their way into the mix. This will cause the cron to fire at the wrong time, or a complete failure.
- Long Wait Times: If your script has long processes it handles and you've manually changed the timeout time in the configurations, this may not be passed to the cron. See if you can shorten the processing time. If you need to try and lengthen the timeout time on the cron, send an email to firstname.lastname@example.org with the details of your cron job.
- Multiple Firings: Most time when you see multiple firings it's actually that the cron is executing an initial part of the script, failing somewhere after that, and trying again. Try setting up a flag, most usually a simple email, at the very end of the code to determine if this is what's causing the double firings.
- No Firings: If your cron is not failing at all, you may need to look at the logs as to why. To do this, send an email to email@example.com. However, the most common reasons for why a cron wouldn't fire at all are below.
- Missing/invalid script path: If you need the script at D:\home\domain.com\wwwroot\myscript.php to fire, but you say it's at D:\home\domain.com\myscript.php then nothing will fire.
- Bad URL: Most crons need to have HTTP:// in front of the URL path. Make sure to check the URL you're using.