1. Enable cron
chmod +x /etc/rc.d/rc.crond
/etc/rc.d/rc.crond start2. Edit crontab
crontab -e
crontab -l3. Cron syntax (5 fields)
* * * * * command
| | | | |
| | | | +-- day of week (0-7)
| | | +---- month (1-12)
| | +------ day of month (1-31)
| +-------- hour (0-23)
+---------- minute (0-59)4. Useful examples
# Every night at 03:00
0 3 * * * /usr/local/sbin/backup-rsync.sh
# Every 15 minutes
*/15 * * * * /usr/local/sbin/disk-check.sh5. Best practices
- Use absolute paths in commands
- Redirect output to logs
- Test the script manually before scheduling
*/10 * * * * /usr/local/bin/script.sh >> /var/log/script.log 2>&1The cron environment is minimal: variables like
PATH can differ from your interactive shell.6. Debug
tail -n 100 /var/log/messages | grep cron
sh -x /usr/local/bin/script.shQuick checklist
[ ] rc.crond enabled
[ ] Job present in crontab -l
[ ] Script tested manually
[ ] Absolute paths used
[ ] Job logs checked