Description
This tool allows you to automate certain scripts and commands on your site. You can set a command or script to run at a specific time every day, every week, etc. For example, you can set up a Cron job to delete temporary files every week to free up disk space.
More advanced users will have more details in the article CRON tasks — differences between Wget, Curl and PHP.
Usage
- Connect to cPanel.
- Click on the Cron Jobs icon in the ADVANCED panel:
- In the Email box, you can set the e-mail box where you will receive notifications of the Cron jobs performed:
- The Common Settings correspond to the schedule of your Cron job. Choose the execution time:
- In the Command field, give the full path from the root to the PHP script (highly recommended) and click on Add New Cron Job button:
- The Cron job then appears in the table above.
Tips
- We advise you not to run the script every minute. It is better to run it during the night.
- If you receive too many emails from Cron jobs, you can disable this notification by adding this at the end of your task:
>/dev/null 2>&1
. - If you have arguments to give to your script, you should not separate the file argument with a “?”. You simply need to put a space.
- If your script causes execution time problems, then it would be better to call it via the php CLI, in this form:
php-cli -f /home/USERNAME/public_html/modules/cron.php argument=valeur >/dev/null 2>&1