A quick reference for cron โ Linux job scheduling. Bookmark this page.
Crontab Commands
# Edit your crontab
crontab -e
# List your crontab
crontab -l
# Edit another user's crontab
sudo crontab -u username -e
# Remove your crontab
crontab -rCron Syntax
โโโโโโโโโโโโโโ minute (0-59)
โ โโโโโโโโโโโโโโ hour (0-23)
โ โ โโโโโโโโโโโโโโ day of month (1-31)
โ โ โ โโโโโโโโโโโโโโ month (1-12)
โ โ โ โ โโโโโโโโโโโโโโ day of week (0-7, 0 and 7 = Sunday)
โ โ โ โ โ
* * * * * commandCommon Schedules
# Every minute
* * * * * /usr/local/bin/check.sh
# Every 5 minutes
*/5 * * * * /usr/local/bin/monitor.sh
# Every hour at minute 0
0 * * * * /usr/local/bin/hourly.sh
# Daily at 2:30 AM
30 2 * * * /usr/local/bin/backup.sh
# Weekly on Monday at 9 AM
0 9 * * 1 /usr/local/bin/weekly-report.sh
# Monthly on the 1st at midnight
0 0 1 * * /usr/local/bin/monthly-cleanup.sh
# Weekdays at 8 AM
0 8 * * 1-5 /usr/local/bin/workday.sh
# Every 15 minutes during business hours
*/15 8-17 * * 1-5 /usr/local/bin/business-check.sh
# Twice daily at 6 AM and 6 PM
0 6,18 * * * /usr/local/bin/sync.shSpecial Strings
@reboot /usr/local/bin/startup.sh # Run once at boot
@hourly /usr/local/bin/hourly.sh # 0 * * * *
@daily /usr/local/bin/daily.sh # 0 0 * * *
@weekly /usr/local/bin/weekly.sh # 0 0 * * 0
@monthly /usr/local/bin/monthly.sh # 0 0 1 * *
@yearly /usr/local/bin/yearly.sh # 0 0 1 1 *Best Practices
# Always use full paths
0 2 * * * /usr/bin/python3 /opt/scripts/backup.py
# Redirect output to log
0 2 * * * /opt/scripts/backup.sh >> /var/log/backup.log 2>&1
# Suppress output (if using email notifications)
0 2 * * * /opt/scripts/quiet-task.sh > /dev/null 2>&1
# Set environment variables
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
MAILTO=admin@example.com
# Use flock to prevent overlapping runs
*/5 * * * * /usr/bin/flock -n /tmp/job.lock /opt/scripts/slow-job.shSystem Cron Directories
/etc/cron.d/ # System cron jobs (with user field)
/etc/cron.daily/ # Scripts run daily
/etc/cron.hourly/ # Scripts run hourly
/etc/cron.weekly/ # Scripts run weekly
/etc/cron.monthly/ # Scripts run monthlyTips and Tricks
- Use
crontab.guruto validate cron expressions - Use
flockto prevent concurrent execution of long-running jobs - Set
MAILTO=""to disable email notifications - Use systemd timers instead of cron for better logging (see SystemD Cheat Sheet)
- Check
/var/log/cronorjournalctl -u crondfor cron execution logs