0
0
Linux CLIscripting~10 mins

Editing crontab (crontab -e) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Editing crontab (crontab -e)
User runs 'crontab -e'
System opens crontab file in editor
User edits or adds cron jobs
User saves and exits editor
System installs new crontab
Cron daemon schedules tasks
Tasks run at scheduled times
The user opens the crontab file with 'crontab -e', edits or adds scheduled tasks, saves and exits, then the system updates the schedule.
Execution Sample
Linux CLI
crontab -e
# Edit the file to add:
0 7 * * * /home/user/backup.sh
# Save and exit
This opens the crontab editor, adds a job to run backup.sh every day at 7:00 AM, then saves the changes.
Execution Table
StepActionSystem ResponseUser InputResult
1Run 'crontab -e'Opens crontab file in default editorN/ACrontab file ready for editing
2User adds line '0 7 * * * /home/user/backup.sh'File content updatedAdd cron job lineNew job scheduled
3User saves and exits editorSystem reads updated fileSave and exitCrontab updated
4System installs new crontabCron daemon reloads scheduleN/ANew job active
5Cron daemon runs job at 7:00 AMExecutes /home/user/backup.shN/ABackup script runs
6User runs 'crontab -l' to list jobsDisplays current cron jobsN/AShows new job in list
7User exitsNo further actionN/ASession ends
💡 User finishes editing and saves, system installs new crontab, then cron daemon schedules tasks accordingly
Variable Tracker
VariableStartAfter Step 2After Step 3Final
crontab file contentEmpty or previous jobsAdded '0 7 * * * /home/user/backup.sh'Saved updated contentUpdated crontab with new job
cron daemon scheduleOld scheduleNo change yetReloads new scheduleSchedules new job daily at 7:00 AM
Key Moments - 3 Insights
Why doesn't the new cron job run immediately after editing?
Because the cron daemon only reads the updated crontab after you save and exit the editor, as shown in steps 3 and 4 in the execution table.
What happens if you forget to save before exiting the editor?
The system will not install the new crontab, so your changes are lost. The execution table step 3 shows saving is required to update the schedule.
How can you verify your new cron job was added?
By running 'crontab -l' which lists current cron jobs, as shown in step 6 of the execution table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what happens at step 4?
ACron daemon runs the scheduled job
BUser edits the crontab file
CSystem installs the new crontab and cron daemon reloads schedule
DUser lists current cron jobs
💡 Hint
Check the 'System Response' and 'Result' columns at step 4 in the execution table
At which step does the user save and exit the editor?
AStep 3
BStep 2
CStep 1
DStep 5
💡 Hint
Look for 'User saves and exits editor' in the 'Action' column of the execution table
If the user forgets to save the file, what will the cron daemon schedule?
AThe new job will be scheduled anyway
BThe old schedule remains unchanged
CThe cron daemon will show an error
DThe cron daemon will delete all jobs
💡 Hint
Refer to the key moment about saving changes and step 3 in the execution table
Concept Snapshot
Editing crontab with 'crontab -e':
- Opens your crontab file in an editor
- Add or change scheduled jobs (one per line)
- Save and exit to install changes
- Cron daemon reloads and runs jobs on schedule
- Use 'crontab -l' to list jobs
- Unsaved changes are lost
Full Transcript
When you run 'crontab -e', the system opens your crontab file in a text editor. You can add or edit scheduled tasks by writing lines with timing and commands. After editing, you must save and exit the editor. The system then installs the new crontab, and the cron daemon reloads the schedule to run your tasks at the specified times. You can check your current cron jobs anytime with 'crontab -l'. Remember, if you do not save before exiting, your changes will not be applied.