cron is the classic Linux scheduler. It runs commands on a
schedule you define. Every DevOps engineer meets it within their
first month, and it hasn't fundamentally changed in decades.
A cron schedule is five space-separated fields:
┌───── minute (0 - 59)
│ ┌───── hour (0 - 23)
│ │ ┌───── day of month (1 - 31)
│ │ │ ┌───── month (1 - 12)
│ │ │ │ ┌───── day of week (0 - 6, Sunday is 0 and 7)
│ │ │ │ │
* * * * * command to run
* means "every value". Combine them to express a schedule:
0 3 * * * # every day at 03:00
*/5 * * * * # every 5 minutes
0 * * * * # top of every hour
0 0 * * 0 # every Sunday at midnight
30 2 1 * * # 02:30 on the 1st of every month
When you're stuck writing a schedule, crontab.guru is a good sanity check.
Each user has their own crontab file. You never edit it directly. Instead:
crontab -e # open your crontab in the default editor
crontab -l # list your current crontab
crontab -r # remove your entire crontab (be careful)
crontab -e opens $EDITOR (usually nano or vim). Save and quit,
and cron picks up the change automatically. No daemon reload
needed.