← WA Computer Science ATAR Unit 1

Scheduling a task to run automatically

A scheduler that runs a command or script at set times without a person starting it, such as a nightly backup. Windows Task Scheduler does the same job.

Understanding Scheduling a task to run automatically in WA Computer Science ATAR Unit 1

What it does: The minute is 30, the hour is 23 (11 pm), and the last field 5 means Friday. The two stars in the middle mean every day of the month and every month. The schtasks command creates a Task Scheduler task. /tn names it, /tr gives the program to run, /sc daily sets the schedule and /st 22:00 sets the start time, so it runs without a person starting it. A scheduler starts the task for you at the times you set, so no one has to remember to run it. cron is the scheduler on Linux and macOS. Windows uses Task Scheduler for the same job.

Common mistakes: A cron expression needs five time fields (minute, hour, day of month, month, weekday). This line has only four, so cron reads the path as a field. It should be 0 2 * * * before the command. The fourth field is the month, so this job would only run in January. Monday is set in the fifth (weekday) field, so the line should be 0 5 * * 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 315–470) and word search (Modules 100–470).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does a scheduler such as cron or Task Scheduler do?
Runs a script only when a person clicks itRuns a command or script at set times without a person starting it
Matches
2 0 * * * /home/user/backup.sh (meant to run at 2:00 am)
↓
The minute and hour fields are in the wrong order. This runs at 12:02 am, not 2:00 am. It should be 0 2 * * *.
Applying
Meanings
Term
cron
Meaning
A scheduler that runs a command or script at set times without a person starting it, such as a nightly backup. Windows Task Scheduler does the same job.
Practice
30 2 * * * python3 /home/sam/backup.py
Testing
Gaps
0 * * * /home/ava/backup.sh
Check Answer
Spots
10 2 * * /home/ann/backup.sh
230 6 * * 1 /home/ann/clean.sh

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Angelfish' badge — Reef Perfectionist, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does a scheduler such as cron or Task Scheduler do?
A. Runs a command or script at set times without a person starting it ✓
B. Runs a script only when a person clicks it
A scheduler starts the task for you at the times you set, so no one has to remember to run it.
2. Which tool is the built-in task scheduler on Windows?
A. Windows Task Scheduler ✓
B. cron
cron is the scheduler on Linux and macOS. Windows uses Task Scheduler for the same job.
3. In a cron expression, what does 30 2 * * * mean?
A. Run every 30 minutes for 2 hours
B. Run every day at 2:30 am ✓
The fields are minute, hour, day of month, month, day of week. So 30 2 means 2:30 am, and the stars mean every day.
4. Which cron expression runs a backup at 11:00 pm every day?
A. 23 0 * * * /home/backup.sh
B. 0 23 * * * /home/backup.sh ✓
The minute comes first, then the hour. 0 23 means minute 0 of hour 23 (11 pm). 23 0 would run at 12:23 am.
5. Why is a scheduler useful for automated backups?
A. The backup runs every night even if the user forgets ✓
B. The backup is never needed again after the first run
Scheduled backups happen reliably at set times, so data is protected without relying on someone's memory.

Match the Pairs

0 2 * * * python3 backup.py → A cron entry that runs backup.py automatically at 2:00 am every day
@reboot /home/user/sync.sh → A cron entry that runs sync.sh each time the computer starts up
Run a backup script automatically at 11:30 pm every Friday using a cron expression → 30 23 * * 5 /home/user/backup.sh
Windows Task Scheduler can create a daily task that starts a backup program from the command line → schtasks /create /tn Backup /tr backup.bat /sc daily /st 22:00
2 0 * * * /home/user/backup.sh (meant to run at 2:00 am) → The minute and hour fields are in the wrong order. This runs at 12:02 am, not 2:00 am. It should be 0 2 * * *.
0 2 * * backup.sh → Only four time fields are given, so cron reads backup.sh as the fifth time field. A cron entry needs five time fields, such as 0 2 * * * backup.sh.

Key Term

cron
A scheduler that runs a command or script at set times without a person starting it, such as a nightly backup. Windows Task Scheduler does the same job.

Fill in the Blanks

1. # Run backup.sh at 2am every day 0 2 * * * /home/ava/backup.sh
Hint: Type the hour field value, using the 24-hour clock
2. # Run backup.sh once at start-up @reboot /home/ava/backup.sh
Hint: Type the cron keyword that runs a job when the computer starts
3. # Edit your list of scheduled cron jobs crontab -e
Hint: Type the command name used to edit the cron job table
4. # Windows Task Scheduler: run every day schtasks /create /tn "Backup" /sc daily
Hint: Type the word that sets how often the task repeats
5. # Run backup.sh every day at 6:30pm 30 18 * * * /home/ava/backup.sh
Hint: Type the value for the minute field, the first field in the cron expression

Spot the Error

Question 1
A 0 2 * * /home/ann/backup.sh
B 30 6 * * 1 /home/ann/clean.sh
C @reboot /home/ann/start.sh
Line A — A cron expression needs five time fields (minute, hour, day of month, month, weekday). This line has only four, so cron reads the path as a field. It should be 0 2 * * * before the command.
Question 2
A # Monthly report, 1st at 9 am
B 0 9 1 * * /home/ann/report.sh
C # Weekly clean, Mon at 5 am
D 0 5 * 1 * /home/ann/clean.sh
Line D — The fourth field is the month, so this job would only run in January. Monday is set in the fifth (weekday) field, so the line should be 0 5 * * 1.
Question 3
A crontab -l
B 3 0 * * 0 /home/ann/backup.sh
C # Runs Sunday at 3:00 am
Line B — Cron puts the minute first and the hour second. 3 0 means 12:03 am, not 3:00 am. It should be 0 3 * * 0.
Question 4
A schtask /query /tn Backup
B schtasks /run /tn Backup
C schtasks /end /tn Backup
Line A — The Windows Task Scheduler command line tool is called schtasks, with an s on the end. The line should be schtasks /query /tn Backup.
Question 5
A # Daily backup at 1:15 am
B # min hour day month weekday
C 15 1 1 * * python3 backup.py
Line C — The third field is the day of the month. Putting 1 there makes the backup run only on the 1st of each month. Use * so it runs every day: 15 1 * * *.

Student with a class code? Join your class →