Mission 2 of 5
Scheduling Without Breaking Your Crontab
Design a scheduled task and test its command before touching crontab.
Learn cron syntax and safe scheduling concepts without requiring changes to your real user crontab.
Mental model
Understand what is happening
cron runs commands on a schedule.
crontab -r removes the whole user crontab, so avoid it while learning.
A shell loop can simulate repeated work inside the sandbox.
Guided lab
Work through the mission
Read current crontab
Checks that the crontab command exists before listing entries, and distinguishes a missing tool from an empty or inaccessible user crontab. Scheduling also requires a working cron-compatible service.
if ! command -v crontab >/dev/null; then
echo "crontab is not installed in this environment"
else
crontab -l 2>/dev/null || echo "No user crontab exists, or access is unavailable"
fiSafe scheduling simulation
Simulates repeated scheduled work without editing crontab.
cd ~/linux-practice
mkdir -p logs
for i in {1..3}; do echo "Simulated run at $(date)" >> logs/schedule-demo.log; sleep 2; done
cat logs/schedule-demo.logDangerous cleanup example
Removes the entire user crontab. Explanation only; do not use as course cleanup.
crontab -rCheckpoint
Verify the mission
The command succeeds manually before any schedule is proposed.
Try it yourself
One step without a recipe
Write out what this means: */5 * * * * command. Run the safe scheduling simulation.
Need a hint?
Write cron jobs with full paths. Cron has a minimal environment—usually not your interactive PATH or aliases. For this course, use `$HOME/linux-practice/scripts/backup.sh` while testing interactively, then put the resolved absolute path from `realpath` into a real crontab. WSL also needs a running scheduler service.
Explain it back
Before you move on
- What does crontab -l do?
- Why is crontab -r dangerous for beginners?