A cron job is an automated task scheduled to run at fixed times or intervals on a server — without any human involvement. It's one of the oldest and most reliable ways to automate repetitive work in software development. This guide covers everything: what cron jobs are, how cron expressions work, real-world use cases, platform differences, and common mistakes.
A cron job is a scheduled task that a Unix or Linux server runs automatically at a defined time. The word "cron" comes from Kronos, the Greek personification of time — via Ken Thompson's implementation of the Unix scheduler in 1975. The scheduler itself is called the cron daemon (crond), a background process that reads a crontab (cron table) file and fires commands at the right moment.
Think of a cron job as a programmable alarm clock for your server. Instead of ringing a bell, it runs a script, sends an email, backs up a database, or does anything else you'd normally have to do manually. Once configured, it just runs — indefinitely, on schedule, with no human needed.
# This line in crontab runs /scripts/backup.sh every night at 2:00 AM 0 2 * * * /scripts/backup.sh # ↑ ↑ ↑ ↑ ↑ # min hr dom mon dow
Every minute, the crond daemon wakes up, reads all the crontab files on the system, and checks whether any scheduled job matches the current time. If there's a match, it spawns a child process and runs the command. The daemon then goes back to sleep until the next minute.
.bashrc or .profile. Commands that work in your terminal may fail in cron because PATH doesn't include /usr/local/bin or your home directory binaries. Always use absolute paths in cron scripts.A cron expression is a string of 5 space-separated fields that defines the schedule. Each field represents a unit of time. The fields are, in order: minute, hour, day-of-month, month, day-of-week.
| Symbol | Meaning | Example | Result |
|---|---|---|---|
| * | Any value (wildcard) | * in Hour | Every hour |
| */n | Every nth value | */5 in Minute | Every 5 minutes |
| a-b | Range from a to b | 1-5 in Day/Week | Monday to Friday |
| a,b,c | Specific values | 1,3,5 in Day/Week | Mon, Wed, Fri |
| n | Exact value | 9 in Hour | At 9:00 AM (of current schedule) |
Click any schedule below to see how the 5 fields map to a real-world use case.
Cron jobs are used everywhere in production systems. Here are the most common use cases developers rely on:
Standard 5-field cron syntax works on Linux, but every cloud platform and framework has its own variation. The core concept is the same — only the format and constraints differ.
python backup.py/usr/bin/python3 /home/ubuntu/scripts/backup.py0 9 * * * (expecting 9am IST)30 3 * * * (9am IST = 3:30am UTC)0 2 * * * /scripts/backup.sh0 2 * * * /scripts/backup.sh >> /var/log/backup.log 2>&1*/1 * * * * slow-task.sh (task takes 3 min)Use a lock file: flock -n /tmp/task.lock slow-task.shAdding untested scripts to crontabRun /scripts/backup.sh manually as the cron user firstNow that you understand how cron jobs work, use our free cron expression builder to create any schedule visually — no syntax memorisation needed. Get plain-English confirmation, next run times, and copy-ready code for your platform.