Find us on social media
CronAutomationcPanel4 min read
Schedule tasks with Cron Jobs in cPanel
Create cron jobs, common schedules, PHP scripts via cron and troubleshooting.
What are Cron Jobs?
Cron Jobs are scheduled tasks that run automatically at defined intervals. They are useful for backups, sending emails, cache cleanup, data updates and more.
Create a Cron Job in cPanel
- Log in to cPanel
- Go to Advanced → Cron Jobs
- Configure the schedule:
- Minute: 0-59
- Hour: 0-23
- Day of month: 1-31
- Month: 1-12
- Day of week: 0-6 (0 = Sunday)
- Enter the command
- Click Add New Cron Job
Common schedules
| Frequency | Minute | Hour | Day | Month | Week |
|---|---|---|---|---|---|
| Every 5 minutes | */5 | * | * | * | * |
| Every hour | 0 | * | * | * | * |
| Daily at 3 AM | 0 | 3 | * | * | * |
| Weekly (Monday) | 0 | 2 | * | * | 1 |
| Monthly (1st) | 0 | 4 | 1 | * | * |
cPanel also offers shortcuts: "Once Per Minute", "Once Per Hour", "Once Per Day", etc.
Run PHP scripts via Cron
bash
# Run a PHP script
/usr/local/bin/php /home/user/public_html/script.php
# With specific PHP version
/usr/local/bin/ea-php83 /home/user/public_html/cron/task.php
# Pass parameters
/usr/local/bin/php /home/user/public_html/cron/send-emails.php --type=newsletterWordPress Cron
WordPress has its own cron system that depends on visits. To make it more reliable:
- Disable WordPress cron in
wp-config.php:
php
define('DISABLE_WP_CRON', true);- Create a real cron in cPanel:
bash
# Run wp-cron every 5 minutes
*/5 * * * * /usr/local/bin/php /home/user/public_html/wp-cron.php > /dev/null 2>&1
# Or via wget
*/5 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1Email notifications
By default, cron sends an email with the output of each execution.
Configure notification email
In the Cron Email section, enter your email address.
Silence the output
If you do not want to receive emails:
bash
# Redirect all output to /dev/null
/usr/local/bin/php /home/user/script.php > /dev/null 2>&1Only receive errors
bash
# Redirect stdout but keep stderr
/usr/local/bin/php /home/user/script.php > /dev/nullTroubleshooting
Cron does not execute
- Verify the full path to the PHP interpreter:
bash
which php
# Typical result: /usr/local/bin/php- Verify script permissions:
bash
chmod 755 /home/user/public_html/cron/script.php- Test the command manually via SSH:
bash
/usr/local/bin/php /home/user/public_html/cron/script.phpCommon errors
- Permission denied: Check file permissions (755)
- No such file: Use full absolute paths
- PHP Fatal error: Check the script for syntax errors
Practical examples
bash
# Daily database backup
0 3 * * * mysqldump -u user -pPASS dbname > /home/user/backups/db-$(date +\%Y\%m\%d).sql
# Clean temporary files weekly
0 4 * * 0 find /home/user/public_html/tmp -type f -mtime +7 -delete
# Send weekly report
0 9 * * 1 /usr/local/bin/php /home/user/public_html/cron/weekly-report.phpRecommendations
- Always use absolute paths in commands
- Redirect output to avoid unnecessary emails
- Do not schedule heavy tasks during high-traffic hours
- Document each cron job with a comment in the command
- Periodically verify that crons are executing correctly
Was this guide helpful?