A cron job is a command that your hosting account runs on a schedule, for example every 15 minutes or once a night. You use it to run WordPress scheduled tasks reliably, send queued emails, clear a cache or run a script your developer gave you.
The short answer: log in to cPanel, open Cron Jobs in the Advanced section, choose a schedule, paste the command and click Add New Cron Job. The steps below show exactly what to fill in.
Before you start
- You need your cPanel login. See how to log in to cPanel.
- Know the exact command or the full path to the script you want to run. Scripts live under your home folder, for example
/home/yourusername/public_html/script.php. Your cPanel username is shown in the General Information panel on the cPanel home page. - Do not run jobs more often than they need. Every run uses your account’s CPU and memory, which count towards your resource limits.
How to create a cron job
- Log in to cPanel.
- In the Advanced section, click Cron Jobs. You can also type “cron” in the search box at the top.
- Optional: under Cron Email, enter the email address that should receive each job’s output and click Update Email. Leave it empty if you do not want emails.
- Scroll to Add New Cron Job.
- Open the Common Settings menu and pick a schedule, such as Once Per Hour or Twice Per Day. This fills in the Minute, Hour, Day, Month and Weekday fields for you. You can also type your own values in those fields.
- In the Command box, enter the full command. Use full paths, not shortcuts.
- Click Add New Cron Job. The job now appears in the Current Cron Jobs table at the bottom of the page.
To change or remove a job later, find it under Current Cron Jobs and click Edit (then Edit Line to save) or Delete (then confirm with Delete).
Reading the schedule fields
A cron schedule has five fields: minute, hour, day of the month, month and day of the week. An asterisk (*) means “every”.
| Schedule | Minute | Hour | Day | Month | Weekday |
|---|---|---|---|---|---|
| Every 15 minutes | */15 |
* |
* |
* |
* |
| Every hour, on the hour | 0 |
* |
* |
* |
* |
| Every day at 02:00 | 0 |
2 |
* |
* |
* |
| Every Sunday at 03:30 | 30 |
3 |
* |
* |
0 |
| First day of each month at 01:00 | 0 |
1 |
1 |
* |
* |
Cron uses the server’s clock, which may not match South African time. If timing matters, add a test job that runs once and records the time, for example date > /home/yourusername/cron-time.txt, then compare it with your clock and delete the job.
Example: run WordPress scheduled tasks properly
WordPress has its own task runner, wp-cron, but it only runs when someone visits the site. On a quiet site, scheduled posts and plugin tasks can run late. On a busy site, it runs on many page loads. A real cron job fixes both.
-
Open File Manager, go to your WordPress folder (usually
public_html) and editwp-config.php. -
Above the line that says
/* That's all, stop editing! */, add:define( 'DISABLE_WP_CRON', true ); -
Save the file.
-
In cPanel, open Cron Jobs and set the fields to
*/15 * * * *(every 15 minutes). -
In Command, enter (replace the domain with yours):
wget -q -O /dev/null https://yourdomain.co.za/wp-cron.php >/dev/null 2>&1 -
Click Add New Cron Job.
This follows the method in the WordPress developer handbook: Hooking WP-Cron into the system task scheduler. If your site has several WordPress installs, add one job per site.
Example: run a PHP script directly
To run a PHP file without going through the website, call PHP with the full path to the file:
/usr/local/bin/php /home/yourusername/public_html/path/to/script.php >/dev/null 2>&1
PHP runs using the version set for your account in Select PHP Version. If the script needs a newer version, change it there first. See how to change your PHP version.
Stop the emails
Every cron job emails its output to the Cron Email address. To stop emails for one job, end its command with >/dev/null 2>&1. To stop them for all jobs, clear the Cron Email field and click Update Email. Keep emails on while you test a new job: they show you any errors.
Troubleshooting
- The job never seems to run. Check the email output. “Command not found” or “No such file or directory” means a path is wrong. Use full paths for both the program and the file.
- “Permission denied”. A script you call directly (not through
php) needs execute permission. In File Manager, right-click it, choose Change Permissions and set it to 755. - The site slows down when the job runs. The job is too heavy or runs too often. Space jobs out so one finishes before the next starts, and run heavy work at night.
- wp-cron stopped working after adding the define. The cron job is missing or the URL is wrong. Open the URL in your browser: a blank page is normal, an error is not.
- Be careful with
rm. A cron job that deletes files with a wrong path can remove your whole site. Test the command in a safe folder first and keep a backup.
Frequently Asked Questions
How often can a cron job run?
The shortest interval cron supports is every minute, but very few tasks need that. For WordPress, every 15 minutes is enough for most sites. Frequent jobs use more of your account’s resources.
Do I need a cron job for WordPress?
No, wp-cron works without one. A server cron job is worth adding if scheduled posts publish late, if you run WooCommerce or a membership plugin with timed tasks, or if your site is busy and you want to cut the work done on page loads.
What time zone does cron use?
It uses the server’s time, which may differ from South African time (SAST). Use the test job described above to check, then set your hours to match.
Can you set up a cron job for me?
Yes. Open a ticket with the command or script you want to run and how often, and we will help you set it up.
Related guides
- How to use the File Manager in cPanel
- Understanding resource usage and CloudLinux limits
- WordPress performance optimisation tips
- WordPress hosting
Need help?
If a cron job is not doing what you expect, open a support ticket with the command and the error from the cron email, or message us on WhatsApp from our contact page.