Hosting and cPanel

Cron jobs (automated tasks)

Introduction and overview

Cron jobs are commands scheduled to run repeatedly, for example every Saturday and Sunday at 12 p.m. They let you automate commands and scripts on your server so repetitive tasks are easier to run. For instance, you could create a cron job that sends email notices every X days. This system process runs in the background.

Create and use a cron job

You manage cron jobs in cPanel.

  1. Sign in to your control panel and click Advanced Tools > Cron Jobs.
  2. Enter the command to run and its schedule, then click Add New Cron Job.

Examples

To run a PHP script called script.php located in your /public_html/ folder, you can use the following cron command:

Shell
/usr/local/bin/php -q /home/username/public_html/script.php

Replace /home/username/public_html/script.php with your script’s absolute path. Also confirm the PHP executable path and version with your hosting provider: /usr/local/bin/php is an example to adapt to your environment.

Cron can email command output to the address configured in cPanel. This email is not an automatic success confirmation: a silent command can succeed without producing one.

After testing the task, appending >/dev/null 2>&1 discards both standard output and error messages. This also hides useful diagnostic information, so keep suitable logging if you use this redirection.

Allow enough time between runs for the previous execution to finish. Consult cPanel’s cron documentation and its explanation of email notifications.

To remove a scheduled task, see our guide to deleting cron jobs.

For help with a Nuagerie service, see our Support page. For general questions, see our Contact page.