Cron Jobs
Cron Jobs
Schedule automated tasks and scripts to run at specific intervals.
Creating Cron Jobs
- Click Add Cron Job
- Configure schedule:
- Minute: 0-59 or * for any
- Hour: 0-23 or * for any
- Day: 1-31 or * for any
- Month: 1-12 or * for any
- Weekday: 0-6 (0=Sunday) or * for any
- Enter command to execute:
- PHP script:
php /path/to/script.php - Shell script:
/path/to/script.sh - Program:
/usr/bin/program
- PHP script:
- Set output:
- Discard: Ignore output
- Email: Send output to email
- Save: Log to file
- Click Create
Common Cron Patterns
| Pattern | Meaning |
|---|---|
0 0 * * * |
Daily at midnight |
0 * * * * |
Hourly |
0 2 * * 0 |
Weekly (Sunday 2am) |
0 0 1 * * |
Monthly (1st day) |
*/15 * * * * |
Every 15 minutes |
0 6,18 * * * |
Twice daily (6am & 6pm) |
30 2 * * * |
Daily at 2:30am |
Managing Cron Jobs
View Job Details:
- Click cron job in list
- View:
- Schedule pattern
- Command
- Last run time
- Next run time
- Status
Edit Cron Job:
- Click Edit
- Modify schedule or command
- Click Save
- Changes take effect immediately
Enable/Disable:
- Click toggle to disable
- Job no longer runs
- Re-enable anytime
Delete Cron Job:
- Click Delete
- Confirm deletion
- Job removed permanently
Viewing Logs
Check Execution:
- Click Logs for cron job
- View recent executions
- Last run time and duration
- Exit status (0 = success)
Troubleshooting:
- View command output in logs
- Check for error messages
- Verify script path is correct
- Test script manually first
Best Practices
- Test commands manually before scheduling
- Use absolute paths (not relative)
- Run resource-heavy jobs during off-peak hours
- Set appropriate output handling
- Monitor cron logs regularly
- Use meaningful job names
- Document purpose of each cron
- Implement error handling in scripts
Example Uses
WordPress Updates:
php /home/user/public_html/wp-cli.phar plugin update --all
Database Cleanup:
mysql -u dbuser -p'password' dbname < /path/to/cleanup.sql
Backup:
/usr/local/bin/backup-script.sh
SSL Renewal Check:
/path/to/ssl-check.sh
[Screenshot: cron-job-list.png] [Screenshot: cron-schedule.png] [Screenshot: cron-logs.png]