Stage 7 · Lesson 7 of 8
Scheduling with cron
runs commands on a schedule, like an alarm clock for scripts. crontab -e opens your list of scheduled jobs. Each line has five time fields: minute, hour, day of the month, month and day of the week.
The command comes after them. So 0 2 * * * ~/bin/backup.sh runs at 2am every day. Cron runs jobs with a bare environment: a short PATH, none of your aliases, and your as the starting point.
So use full paths, and send output to a log with >> ~/logs/backup.log 2>&1. A site like crontab.guru checks what a schedule means. On WSL and laptops, jobs only run while the machine is on.
Common trapa job that works in your terminal and silently fails in cron because of PATH.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- GuideFreeGreg's Wiki: BashGuide
Greg's Wiki (Wooledge) · Beginner
A careful, accurate Bash guide that teaches the habits that avoid most scripting bugs
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The shell tools and scripting lecture, with exercises that build useful small scripts
Practise
Keep handy
Also worth your time
- roadmap.sh: Shell / BashGo deeper
The scripting side of the shell map: arrays, traps, parameter expansion and more