Setting Up Cron Jobs
Cron jobs automatically run scripts or commands at scheduled times (e.g., daily backups, cleanup tasks).
Create a Cron Job
- Log into cPanel
- Go to Advanced > Cron Jobs
- Enter email for notifications (optional)
- Choose schedule:
- Common Settings: Select preset (Once per day, week, month, etc.)
- Or set custom:
- Minute (0-59)
- Hour (0-23)
- Day (1-31)
- Month (1-12)
- Weekday (0-6, 0=Sunday)
- Enter command to run
- Click Add New Cron Job
Common Cron Examples
Daily PHP Script
/usr/local/bin/php /home/username/public_html/cron.php
Schedule: Once per day at midnight
WordPress Cron
wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron
Schedule: Every 15 minutes
Database Backup
/usr/local/bin/mysqldump -u username -p'password' database_name > /home/username/backup.sql
Schedule: Once per week
Cron Schedule Syntax
- * * * * * = Every minute
- 0 * * * * = Every hour
- 0 0 * * * = Daily at midnight
- 0 0 * * 0 = Weekly on Sunday
- 0 0 1 * * = Monthly on 1st
Managing Cron Jobs
Scroll down to see current cron jobs. Click Delete or Edit to manage them.
Troubleshooting
- Check email notifications for errors
- Verify file paths are absolute, not relative
- Ensure script has proper permissions (755)
- Test command manually via SSH first
