Linux, terminal and Git

Stage 7 · Lesson 7 of 8

Scheduling with cron

Shell scripts and automation

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

Practise

Keep handy

  • Paste or run a script to catch quoting and error-handling bugs before they bite

  • Check what each part of an unfamiliar command does before you put it in a script

Also worth your time

Mark this stage as not done?