Set Up a Cron Job in cPanel (Video Guide)
A cron job runs a command on a schedule, with nobody clicking anything. Websites use them to send a daily email, clear old temporary files or run a backup at night. cPanel gives you a simple form for it. This video shows the form, and the steps below follow it.
Before you start
You need your cPanel login and the exact command to run. The command is the part that trips people up. If you are not sure what to type, ask your developer or Sulserv support first, since a wrong command can cause harm. The form itself shows an example of how a PHP script command looks.
Step by step
- Sign in to cPanel and open Cron Jobs in the Advanced section.
- Choose a schedule from Common Settings, such as once per day. cPanel fills in the time fields. You can also set the minute, hour and day yourself.
- Type the command you want to run in the Command field.
- Click Add New Cron Job.
- Find the job in the Current Cron Jobs list. There you can edit or delete it.
Video transcript
This video shows how to set up a cron job in cPanel. We open Cron Jobs and choose a schedule from Common Settings, or set the minute, hour and day ourselves. We type the command we want to run, then click Add New Cron Job. The Current Cron Jobs list shows every job on the account, where we can edit or delete it.
How the time fields work
- Minute: 0 to 59.
- Hour: 0 to 23, so 3 means 3:00 in the morning.
- Day, month and weekday: a star (*) means every day, every month or every weekday.
Minute 0, hour 3 and a star in the other three fields runs a job once a day at 3:00 in the morning. Heavy jobs are best run at night, when your visitors are asleep. Times follow the server clock.
Check that it works
By default the server emails you the result of each run. This is useful at first, because it shows whether the job worked. The Cron Email section at the top of the page shows which address gets these messages. Once you trust the job, you can silence the emails, or keep them and add a filter in your mail app.
Common problems
- The job runs but nothing happens: the command or the path is probably wrong. The email shows the error. You can check file paths in the File Manager, as in our File Manager video.
- Permission denied: the script file may need different permissions. Ask support if you are unsure.
- It runs twice: look for a second job with the same command, and delete the copy.
- The site is slow at the same time every day: a heavy job may run in peak hours. Move it to the night. See our guide on speeding up a slow WordPress site.
Good uses
- A scheduled backup. See our guide on website backups.
- A task for a plugin or an app that asks for a scheduled call. Check its own guide for the exact command.
- Cleaning old files.
If the job runs a PHP script, the PHP version matters. Our PHP version and settings video shows how to see it.
Remove a job
Find the row in Current Cron Jobs and click Delete. The job stops, and your script files stay where they are.
FAQ
Do I need to know how to code?
Not to fill in the form, but you do need the correct command from whoever made the script or plugin.
How often can a job run?
Common Settings lists the usual choices, from once per minute to once per month. Pick the slowest schedule that does the job.
Can I stop a job for a while?
Delete it and add it again later, and keep a note of the command.