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.
In this guide
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 minutes0 * * * *: every hour, on the hour0 2 * * *: every day at 02:000 3 * * 1: every Monday at 03:000 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
- Under Add New Cron Job, choose a common setting or fill in the five fields.
- Enter the command, such as
/usr/local/bin/php /home/username/public_html/script.php. - 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:
- Add
define('DISABLE_WP_CRON', true);towp-config.php. - 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>&1to 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
- cPanel overview: a beginner's guide
- WordPress troubleshooting: common errors and fixes
- Your hosting plan: resources and limits
Stuck? Open a ticket and a person will reply.
