A cron job runs a command on a schedule, such as a script every hour or a clean-up every night. This guide shows how to add one in cPanel and how to read the schedule format.

Open Cron Jobs

In cPanel, open Cron Jobs. At the top you can enter an email address for the output of your jobs. Leave it empty if you don't want an email every time a job runs.

The schedule format

A schedule has five parts: minute, hour, day of the month, month and day of the week. An asterisk (*) means every.

  • */5 * * * *: every 5 minutes
  • 0 * * * *: every hour, on the hour
  • 0 2 * * *: every day at 02:00
  • 0 3 * * 1: every Monday at 03:00
  • 0 0 1 * *: at midnight on the first of every month

Cron uses the server's clock, which may not be on SAST. crontab.guru helps you check a schedule.

Add a cron job

  1. Under Add New Cron Job, choose a common setting or fill in the five fields.
  2. Enter the command, such as /usr/local/bin/php /home/username/public_html/script.php.
  3. Select Add New Cron Job.

Use full paths for both PHP and your script, and replace username with your cPanel username.

WordPress cron

WordPress runs its scheduled tasks when someone visits your site, which can be late on quiet sites and wasteful on busy ones. To use a real cron job instead:

  1. Add define('DISABLE_WP_CRON', true); to wp-config.php.
  2. Add a cron job that runs every 15 minutes, with the command /usr/local/bin/php /home/username/public_html/wp-cron.php >/dev/null 2>&1.

Edit or delete a cron job

Your jobs are listed under Current Cron Jobs. Select Edit to change the schedule or command, or Delete to remove it.

If a job doesn't run

  • Run the script yourself first, to check it works.
  • Check the paths. Cron doesn't know your current folder, so use full paths everywhere.
  • Turn on the email output, or send the output to a file by adding >> /home/username/cron.log 2>&1 to the end of the command.
  • Don't run heavy jobs every minute. Busy cron jobs use up your share of the server. See Your hosting plan: resources and limits.

Related guides

Stuck? Open a ticket and a person will reply.

Was this answer helpful? 0 Users Found This Useful (0 Votes)