What is a Cron Job?
In Unix-like computer operating systems, cron is a background time-based job scheduler (daemon). Systems engineers, DevOps architects, and software developers configure cron jobs to automate periodic routines—such as database backups, log rotations, SSL certificate renewals, cache warmers, and automated maintenance scripts.
The configuration file containing instructions for the cron daemon is known as a crontab (cron table).
Anatomy of a 5-Field Standard Cron Expression
A standard POSIX cron expression is comprised of 5 space-delimited fields:
┌───────────── Minute (0 - 59)
│ ┌─────────── Hour (0 - 23, 24-hour clock)
│ │ ┌───────── Day of the Month (1 - 31)
│ │ │ ┌─────── Month of the Year (1 - 12)
│ │ │ │ ┌───── Day of the Week (0 - 6, where 0 = Sunday)
│ │ │ │ │
* * * * *
Supported Special Characters:
*(Asterisk / Wildcard): Matches every possible value of the field (e.g., every minute or every hour).,(Comma / Value List): Specifies a list of discrete trigger values (e.g.,1,15,30).-(Hyphen / Range): Specifies an inclusive continuous range (e.g.,1-5for Monday through Friday)./(Slash / Step Intervals): Specifies rate increments (e.g.,*/10in the minute field runs every 10 minutes).
Common Crontab Recipes & Examples
| Expression | Schedule Meaning | Standard Use Case |
|---|---|---|
*/5 * * * * | Every 5 minutes | Health checks & API heartbeats |
0 * * * * | Every hour at minute 0 | Hourly analytics rollups |
0 0 * * * | Once a day at midnight (00:00) | Nightly database dumps & backups |
0 2 * * 0 | Every Sunday at 2:00 AM | Heavy weekly disk defrag & cleanup |
0 9 * * 1-5 | Monday through Friday at 9:00 AM | Business hours digest notifications |
0 0 1 * * | Midnight on the 1st of every month | Monthly billing & invoicing generation |
How to Install a Cron Job in Linux / macOS
To install or edit scheduled jobs on your server:
- Open your terminal shell and open your user’s crontab:
crontab -e - Add your schedule and executable command line on a new line:
0 3 * * * /usr/bin/python3 /opt/scripts/backup.py >> /var/log/backup.log 2>&1 - Save and close the editor. The cron daemon reads changes automatically without requiring a service reboot.
- To verify all currently active scheduled routines:
crontab -l