Scheduling: cron & at

cron - recurring jobs

A crontab line has five time fields then the command:

┌ minute (0-59)
│ ┌ hour (0-23)
│ │ ┌ day of month (1-31)
│ │ │ ┌ month (1-12)
│ │ │ │ ┌ day of week (0-7, 0 & 7 = Sunday)
│ │ │ │ │
* * * * *  /path/to/command
CommandAction
crontab -eEdit your crontab
crontab -lList
crontab -rRemove

System-wide: /etc/crontab, /etc/cron.d/, and the /etc/cron.{hourly,daily,weekly,monthly}/ directories.

Examples:

0 2 * * *      backup.sh        # every day at 02:00
*/15 * * * *   check.sh         # every 15 minutes
0 9 * * 1-5    report.sh        # 09:00 on weekdays

at - one-off jobs

$ echo 'reboot' | at 03:00
$ atq          # list pending
$ atrm 3       # remove job 3
Exam tip: systemd timers are the modern alternative to cron (systemctl list-timers).