Automating Tasks with Cron Jobs
Cron jobs are scheduled tasks that run automatically at specified intervals on your hosting account. They are commonly used for scheduled backups, email sending, cache clearing, and WordPress maintenance tasks.
How to Create a Cron Job
- Log in to cPanel
- In the Advanced section, click Cron Jobs
- Under Add New Cron Job, use the dropdowns to set the frequency, or enter the cron expression manually
- Enter the command to run in the Command field
- Click Add New Cron Job
WordPress wp-cron Example
WordPress has its own cron system but it only runs when someone visits your site. To set up a proper server-side cron for WordPress:
- Disable wp-cron by adding this to your wp-config.php:
define('DISABLE_WP_CRON', true); - Create a cPanel cron job to run every 15 minutes:
wget -q -O - https://yourdomain.co.za/wp-cron.php?doing_wp_cron
Common Cron Expressions
| Expression | Runs |
|---|---|
* * * * * |
Every minute |
0 * * * * |
Every hour |
0 0 * * * |
Every day at midnight |
0 0 * * 0 |
Every Sunday at midnight |
Need Assistance?
If you are unsure about setting up a cron job, open a support ticket and our team can help you configure it.