Cron Jobs
From Hostek.com Wiki
Contents
cPanel/Linux - Setting up Cron Jobs
- Please keep in mind that you may have to have a cron job be executed by a specific service.
- For Example a PHP File to be run:
/usr/bin/php -q /home/user/public_html/cron.php
- If you do not want the email to be received for confirmation you will need to add the following to the end of your request:
/usr/bin/php -q /home/user/public_html/cron.php > /dev/null
- If you are using get for a http request it would be like this:
/usr/bin/curl --silent --output /dev/null http://yourdomain.com/cron.php
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 support@hostek.com 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 support@hostek.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.