Linux Automation
Cron Jobs &
Task Scheduling
How Linux runs backups at 2am without anyone touching a keyboard. The scheduler behind every production server's automation.
Sections
5
Read time
15 min
Level
Beginner
Your server, running while you sleep:
What is a Cron Job?
A cron job is a scheduled task β a command that runs automatically at a time you specify. No manual intervention. No staying up at 2am to run the backup.
Cron job = runs at 7am every day β checks disk space, or sends a report, or cleans up old files
What companies use cron for
Key Takeaway
Every production Linux server has dozens of cron jobs running. It's how sysadmin work gets automated β the server does maintenance while you sleep.
The Schedule Format
Every cron job has a schedule written in this exact format. Five fields, then the command:
* * * * * command-to-run
β
β
β
β
β
Minute
0β59
Hour
0β23
Day
1β31
Month
1β12
Weekday
0=Sun..6=Sat
* means "every" β every minute, every hour, every day, etc.
The * wildcard means "every possible value." So * * * * * runs every single minute of every day.
Did You Know?
Reading the Format
Click any example below to see how the format breaks down:
* * * * *βEvery single minute*every (all values)
*/5every 5 of that unit
0at exactly 0 (midnight, top of hour)
1-5a range (Monday through Friday)
1,3,5specific values (Mon, Wed, Fri)
Managing Crontabs
Each user has their own crontab β a file listing their scheduled jobs. You manage it with the crontab command:
Click the Play button above to start!
Watch the commands execute step by step
Key Takeaway
crontab -r removes ALL your cron jobs with no confirmation prompt. Unlike most destructive commands, there's no "are you sure?" Always double-check with crontab -l first.
Real Crontab Examples
Here's what a typical sysadmin's crontab looks like:
# crontab -l output
Logging cron output
By default, cron emails output to the local user β which nobody reads. Better practice: redirect to a log file:
Click the Play button above to start!
Watch the commands execute step by step
Key Concepts Flashcards
Click any card to flip and reveal the definition.