Practice Use drills for recall and labs for real operating judgment.

LAB-AUTO-01 - Cron & Scheduling

Practice reading cron syntax, creating one safe scheduled job, and verifying that it ran as expected.

AUTO Automation & Scheduling

Cron & Scheduling

Practice reading cron syntax, creating one safe scheduled job, and verifying that it ran as expected.

20 min BEGINNER LINUX Field-verified
Success criteria
  • Practice reading cron syntax, creating one safe scheduled job, and verifying that it ran as expected.
  • Repeat the workflow without copy-paste or step-by-step prompting.
Safety notes
  • Schedule jobs against sample files or folders in your home directory until you are confident that the schedule and command behave as expected.

Part A: The Field Guide


What This Lab Is Really About

Scheduling matters because some work should happen on time, not only when you remember it.

Cron is a simple Linux scheduler. It checks a table of jobs every minute and runs any command whose time pattern matches the current minute.

In this lab, the goal is not to schedule something dramatic. The goal is to learn:

  • how to read cron timing
  • how to add one safe job
  • how to verify that it actually ran

Mental Model: A Calendar Plus a Command

Each cron line has five time fields, followed by the command to run:

* * * * * command

From left to right, the fields mean:

  1. minute
  2. hour
  3. day of month
  4. month
  5. day of week

Examples:

  • * * * * * = every minute
  • 0 * * * * = at minute 0 of every hour
  • 30 6 * * 1 = at 06:30 every Monday

Command Reference

Common cron commands

crontab -l crontab -e crontab -r

Use these carefully:

  • crontab -l lists your current jobs
  • crontab -e edits your personal schedule
  • crontab -r removes your personal schedule completely

For learning, stay in your own user crontab. Do not edit root jobs unless you have a specific need and understand the impact.

Why Absolute Paths Matter

Cron runs with a much smaller environment than your interactive shell. Use absolute paths for commands and files whenever possible, such as /usr/bin/date instead of just date.


Part B: The Drill Deck

Terminal required: open a Linux terminal and work in your own home directory.


G
Guided Step by step - type exactly this and compare the result
>

Exercise G1: Read the Current Schedule

  1. List your current cron jobs: crontab -l
  2. If cron says there is no crontab for your user, that is fine.
  3. Open the editor: crontab -e
  4. Read the help text or comments that appear, then exit without saving.

Exercise G2: Find the Paths You Need

  1. Find the full path to date: which date
  2. Print your home directory path: echo $HOME
  3. We will use both values in the scheduled command.

Exercise G3: Add One Safe Job

  1. Open your crontab again: crontab -e
  2. Add this line at the bottom, replacing the date path only if your system showed a different one:
* * * * * /usr/bin/date >> $HOME/cron-practice.log
  1. Save and close the editor.
  2. Confirm the job is installed: crontab -l
S
Solo Task described, hints available - figure it out
>

Exercise S1: Verify the Job Actually Ran

  1. Wait a little over one minute.
  2. Read the log file: cat "$HOME/cron-practice.log"
  3. Wait another minute and read it again.
  4. Confirm that a new timestamp line was appended.

Exercise S2: Remove the Job Cleanly

  1. Open the editor: crontab -e
  2. Delete the line you added.
  3. Save and close.
  4. Run crontab -l again and verify the job is gone.
M
Mission Real scenario - no hints, combine multiple skills
>

Mission M1: Translate the Schedule

Translate each cron expression into plain English:

  1. 0 12 * * * /opt/report.sh
  2. 15 2 * * 1 /opt/cleanup.sh
  3. */10 * * * * /opt/check.sh

Your answer should describe:

  • the minute
  • the hour if relevant
  • whether it runs every day or on specific days