Code-Memo

Cron jobs and scheduling

Cron basics

Cron runs commands on a schedule using entries called crontabs.

Edit user crontab:

crontab -e
crontab -l

Schedule format

Five fields: min hour day month weekday command

Examples:

# Every day at 02:30
30 2 * * * /usr/local/bin/backup.sh

# Every 5 minutes
*/5 * * * * /usr/local/bin/healthcheck.sh

# Every Monday at 09:00
0 9 * * 1 /usr/local/bin/report.sh

Common pitfalls

Logging / email

Cron may email output to the local mailbox depending on configuration.

Alternatives