Cron
Cron is the scheduler of Linux and Unix. The cron service reads crontab files and runs each command when its time matches. The time is written as a cron expression of five fields: minute, hour, day of the month, month and day of the week, for example 30 2 * * * for every day at 02:30.
Key concepts #
- crontab: the file with one schedule and command per line, edited with
crontab -e. - Cron expression:
* * * * *with ranges (1-5), lists (1,15) and steps (*/10). - Environment: cron runs with a minimal
PATH, so use full paths in commands. - Same syntax elsewhere: a Kubernetes
CronJob, a GitHub Actionsscheduleand EventBridge rules use it, with small differences. - Alternative: systemd timers.
Learn it #
Follow Cron expressions with examples. A typical cron task is a backup with rsync.