The crontab command
The crontab command manages your scheduled cron jobs: crontab -e edits the list…
The crontab command manages your scheduled cron jobs: crontab -e edits the list, crontab -l shows it, and each line has five time fields and a command.
Taught in Advanced, lesson 43
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.
Usage
crontab -e crontab -l crontab -r crontab FILE COMMAND | crontab -
Schedule commands to run regularly (cron). Your crontab is a list of jobs for cron to run on a schedule. Each line has five time fields, then the command: minute (0-59), hour (0-23), day of the month, month, and day of the week (0 is Sunday). * means every, */5 every fifth, 1-5 a range, 1,15 a list. So 30 2 * * * backup.sh runs at 2:30 every night and */5 * * * * date >> ~/times.log every five minutes. Use full paths, because cron runs with a short PATH, and send output to a file (>> log 2>&1), or cron mails it to you. In this practice shell the clock moves a minute every time you press Enter, so a job for every minute runs after each command. crontab -e opens a copy in a text editor and installs it when you save and quit; here that editor is the practice Vim (i to type, Esc then :wq to save).
In the practice terminal:cron runs on the practice shell’s clock, which moves a minute each time you press Enter, so a job for every minute runs after each command. crontab -e opens the practice Vim.
How to use crontab
Edit your crontab: crontab -e
It opens a copy of your crontab in a text editor and installs it when you save and quit. In the practice terminal that editor is Vim: press i to type, then Esc and :wq.
crontab -eno crontab for learner - using an empty one
Read the five time fields
Minute, hour, day of the month, month, day of the week (0 is Sunday). * means every, */15 every fifteenth, 1-5 a range and 1,15 a list. So 30 2 * * 1-5 is 2:30 at night, Monday to Friday.
echo "30 2 * * 1-5 /home/learner/backup.sh" | crontab - && crontab -l30 2 * * 1-5 /home/learner/backup.sh
Add a job from the command line
Useful in scripts: list the jobs you have, add a line, and pipe the lot back in.
(crontab -l 2>/dev/null; echo "*/5 * * * * date >> /home/learner/times.log") | crontab - && crontab -l*/5 * * * * date >> /home/learner/times.log
See a job run
cron runs the job when its minute comes. Its output goes where the line sends it, here a log file.
echo "* * * * * date >> /home/learner/times.log" | crontab -sleep 1cat times.logMon Jan 12 09:02:00 UTC 2026 Mon Jan 12 09:03:00 UTC 2026
Remove your crontab: crontab -r
It deletes every job at once, without asking. crontab -l > backup.txt keeps a copy first.
echo "0 9 * * * date" | crontab -crontab -rcrontab -lno crontab for learner
Options
| -e | edit your crontab in a text editor, then install it |
|---|---|
| -l | list your crontab |
| -r | remove it |
| -u USER | another user’s (with sudo) |
More examples
echo "*/2 * * * * date >> /home/learner/times.log" | crontab -Questions about crontab
What does */5 * * * * mean?
Every five minutes: */5 in the minute field means every fifth minute, and * in the other four fields means every hour, day, month and day of the week.
Why does my cron job work in the terminal but not from cron?
cron runs it with a short PATH and none of your shell settings. Use full paths to programs and files, and send the output to a log (>> /home/you/job.log 2>&1) to see the error.
Where are crontabs stored?
Each user’s is in /var/spool/cron/crontabs; change it only through crontab, which checks it before installing. Jobs for the whole system live in /etc/crontab and /etc/cron.d.
Learn it step by step
Related commands
Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.