A cron job is a scheduled task that runs automatically on your server at a fixed interval — every minute, every hour, every Sunday at 3 AM, or any other schedule you can express. cPanel makes setting them up straightforward without ever touching the command line. This article covers the syntax, the common use cases, and the gotchas.
Where to find cron jobs in cPanel
- Log in to cPanel.
- Under Advanced, click Cron Jobs.
- You will see two sections: Cron Email at the top, and Add New Cron Job in the middle.
Set up email notifications first
Before adding any cron job, set the Cron Email address. cPanel will email you the output of every cron run. By default this is too noisy — most cron jobs produce some output even on success. Two options:
- Set the email to a real address you check, then add
> /dev/null 2>&1to the end of each cron command (suppresses both stdout and stderr). - Or, leave the field blank to disable email entirely.
Most experienced users go with the second approach and add their own logging inside the script.
Cron syntax: 5 fields
Cron schedules use 5 space-separated fields:
* * * * * command-to-run | | | | | | | | | +-- Day of week (0-6, Sunday=0) | | | +---- Month (1-12) | | +------ Day of month (1-31) | +-------- Hour (0-23) +---------- Minute (0-59)
Each field accepts:
- A specific number:
5means at minute 5, hour 5, etc. - An asterisk (*): means "every" —
* * * * *runs every minute. - A range:
1-5means 1 through 5. - A list:
1,15,30means at those exact values. - A step:
*/5means every 5 (every 5 minutes, every 5 hours, etc.).
Common schedules
| Schedule | Cron expression |
| Every minute | * * * * * |
| Every 5 minutes | */5 * * * * |
| Every hour at :00 | 0 * * * * |
| Every day at 3 AM | 0 3 * * * |
| Every Sunday at 4 AM | 0 4 * * 0 |
| 1st of every month at midnight | 0 0 1 * * |
| Weekdays at 9 AM | 0 9 * * 1-5 |
cPanel also offers a Common Settings dropdown for these without having to remember the syntax.
Adding a cron job
- In the Add New Cron Job section, pick a Common Setting or fill in each of the 5 fields manually.
- Enter the command in the Command field.
- Click Add New Cron Job.
Common cron use cases
WordPress: replacing wp-cron.php with a real cron
By default, WordPress runs its scheduled tasks (publishing scheduled posts, sending notifications, plugin maintenance) via wp-cron.php, which fires on every page load. On low-traffic sites scheduled tasks miss; on high-traffic sites it slows page loads. The fix:
- Add this cron job:
*/15 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1 - Edit your
wp-config.phpand add:define('DISABLE_WP_CRON', true);
Now WordPress scheduled tasks run reliably every 15 minutes regardless of traffic.
Database backups
To dump a MySQL database to a file every night at 2 AM:
0 2 * * * /usr/bin/mysqldump -u dbuser -pPASSWORD dbname > /home/USERNAME/backups/db-$(date +\%Y\%m\%d).sql 2>/dev/null
Note: the % character must be escaped as \% in cron syntax. Replace USERNAME, dbuser, dbname, and PASSWORD with your values.
Periodic Laravel/PHP scripts
Most modern PHP frameworks expect a single cron entry that fires their internal scheduler every minute:
* * * * * /usr/local/bin/php /home/USERNAME/public_html/artisan schedule:run >> /dev/null 2>&1
Testing your cron job
To verify a cron job runs without waiting for its next scheduled time, just run the command directly via SSH or via cPanel's Terminal feature. If it fails interactively, it will fail in cron too. Cron failures are usually:
- Wrong path to the executable: use full paths like
/usr/local/bin/phpnot justphp. - Wrong working directory: cron runs in your home directory by default. Use absolute paths to scripts and data files, or
cdfirst. - Missing environment variables: cron has a minimal environment. If your script needs
PATHor other vars, set them inside the script.
Common pitfalls
- Excessive frequency. Cron jobs running every minute can get you firewalled if they're hitting your own site over HTTP. Once every 5 minutes is plenty for most use cases.
- Long-running jobs overlapping. If a job takes longer than its schedule interval, two copies can run simultaneously. Wrap with
flockif this is a concern:flock -n /tmp/myjob.lock command - Output filling your mailbox. Set Cron Email to blank, or redirect output as shown above.
- Quotas. Cron jobs that write files count against your disk quota. Make sure your job doesn't silently fail because the disk is full.