Cron Jobs

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

  1. Connect to cPanel.
  2. Click on the Cron Jobs icon in the ADVANCED panel:
  1. In the Email box, you can set the e-mail box where you will receive notifications of the Cron jobs performed:
  1. The Common Settings correspond to the schedule of your Cron job. Choose the execution time:
  1. 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:
  1. The Cron job then appears in the table above.

Tips

  1. We advise you not to run the script every minute. It is better to run it during the night.
  2. 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.
  3. 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.
  4. 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
Updated on 28 January 2022

Was this article helpful?

Related Articles