Bird
Raised Fist0
Linux CLIscripting~20 mins

Why cron automates recurring tasks in Linux CLI - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Cron Automation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is cron used for recurring tasks?
Which of the following best explains why cron is used to automate recurring tasks on Linux systems?
ACron is used to manually start tasks on demand.
BCron executes commands only once when the system boots up.
CCron runs commands at scheduled times repeatedly without manual intervention.
DCron requires user input every time it runs a task.
Attempts:
2 left
💡 Hint
Think about what 'recurring' means and how cron handles timing.
💻 Command Output
intermediate
2:00remaining
Output of a cron job listing
What is the output of the command `crontab -l` if the user has these two cron jobs set? 1. Runs a backup script every day at 2 AM 2. Runs a cleanup script every Sunday at 3 AM
Linux CLI
0 2 * * * /home/user/backup.sh
0 3 * * 0 /home/user/cleanup.sh
A
0 2 * * * /home/user/backup.sh
0 3 * * 0 /home/user/cleanup.sh
B
Runs backup.sh at 3 AM every Sunday
Runs cleanup.sh at 2 AM daily
C
backup.sh runs once at 2 AM
cleanup.sh runs once at 3 AM Sunday
DNo cron jobs scheduled
Attempts:
2 left
💡 Hint
The `crontab -l` command lists the cron jobs exactly as scheduled.
📝 Syntax
advanced
2:00remaining
Identify the correct cron schedule syntax
Which cron schedule line correctly runs a script every 15 minutes?
A* 15 * * * /usr/bin/script.sh
B15 * * * * /usr/bin/script.sh
C0 15 * * * /usr/bin/script.sh
D*/15 * * * * /usr/bin/script.sh
Attempts:
2 left
💡 Hint
Look for the syntax that means 'every 15 minutes' in the minutes field.
🔧 Debug
advanced
2:00remaining
Why does this cron job not run?
A user added this cron job to run a script every day at 1 AM: `0 1 * * * /home/user/myscript.sh` But the script never runs. What is the most likely reason?
AThe script does not have execute permission.
BThe cron syntax is invalid.
CCron does not support running scripts at 1 AM.
DThe user must reboot the system for cron jobs to start.
Attempts:
2 left
💡 Hint
Check if the script can be run manually first.
🚀 Application
expert
2:00remaining
Determine the number of times a cron job runs in a week
A cron job is scheduled as: `30 6 * * 1-5 /usr/bin/task.sh` How many times will this job run in one week?
A7 times
B5 times
C1 time
D0 times
Attempts:
2 left
💡 Hint
Look at the day-of-week field and count the days it covers.

Practice

(1/5)
1. Why do people use cron to automate tasks on Linux systems?
easy
A. To run tasks automatically at set times without manual effort
B. To speed up the computer's hardware components
C. To create graphical user interfaces for applications
D. To permanently delete files from the system

Solution

  1. Step 1: Understand the purpose of cron

    cron is a tool that schedules tasks to run automatically at specified times.
  2. Step 2: Identify the benefit of automation

    Automating tasks saves time and prevents forgetting to run important jobs manually.
  3. Final Answer:

    To run tasks automatically at set times without manual effort -> Option A
  4. Quick Check:

    Cron automates tasks = To run tasks automatically at set times without manual effort [OK]
Hint: Cron runs tasks on schedule to save time and effort [OK]
Common Mistakes:
  • Thinking cron speeds up hardware
  • Confusing cron with GUI tools
  • Believing cron deletes files permanently
2. Which of the following is the correct syntax for a cron schedule line to run a task every day at 3 AM?
easy
A. 3 0 * * * /path/to/script.sh
B. 0 3 * * * /path/to/script.sh
C. * 3 * * * /path/to/script.sh
D. 0 0 3 * * /path/to/script.sh

Solution

  1. Step 1: Understand cron time fields

    The five fields are: minute, hour, day of month, month, day of week.
  2. Step 2: Match 3 AM daily schedule

    Minute = 0, Hour = 3, and all other fields as * to mean every day.
  3. Final Answer:

    0 3 * * * /path/to/script.sh -> Option B
  4. Quick Check:

    Minute=0, Hour=3 daily = 0 3 * * * /path/to/script.sh [OK]
Hint: Minute first, then hour; 3 AM is hour 3, minute 0 [OK]
Common Mistakes:
  • Swapping hour and minute fields
  • Using * for minute instead of 0
  • Misplacing day or month fields
3. Given this cron entry: 30 2 * * 1 /usr/bin/backup.sh, what does it do?
medium
A. Runs backup.sh every hour at 2:30
B. Runs backup.sh every day at 2:30 AM
C. Runs backup.sh every Monday at 2:30 AM
D. Runs backup.sh every minute on Mondays

Solution

  1. Step 1: Decode the cron time fields

    30 = minute, 2 = hour, * = every day/month, 1 = Monday (day of week).
  2. Step 2: Interpret the schedule

    The command runs at 2:30 AM only on Mondays.
  3. Final Answer:

    Runs backup.sh every Monday at 2:30 AM -> Option C
  4. Quick Check:

    Minute=30, Hour=2, Day=Monday = Runs backup.sh every Monday at 2:30 AM [OK]
Hint: Day of week 1 means Monday; time is hour then minute [OK]
Common Mistakes:
  • Assuming it runs daily instead of weekly
  • Mixing up day of week with day of month
  • Confusing minute and hour positions
4. A user writes this cron line: 60 24 * * * /home/user/script.sh. What is wrong?
medium
A. Minute value 60 is invalid; should be 0-59
B. Nothing is wrong; it will run daily at midnight
C. Hour value 24 is invalid; should be 0-23
D. Both minute and hour values are invalid

Solution

  1. Step 1: Check minute field validity

    Minute must be between 0 and 59; 60 is invalid.
  2. Step 2: Check hour field validity

    Hour must be between 0 and 23; 24 is invalid.
  3. Final Answer:

    Both minute and hour values are invalid -> Option D
  4. Quick Check:

    Minute=60 and Hour=24 invalid = Both minute and hour values are invalid [OK]
Hint: Minutes 0-59, hours 0-23 only [OK]
Common Mistakes:
  • Thinking 60 minutes means next hour
  • Assuming 24 is valid hour for midnight
  • Ignoring cron field limits
5. You want to automate a cleanup script to run every 15 minutes using cron. Which cron schedule line is correct?
hard
A. */15 * * * * /usr/local/bin/cleanup.sh
B. 15 * * * * /usr/local/bin/cleanup.sh
C. 0,15,30 * * * * /usr/local/bin/cleanup.sh
D. 0-15 * * * * /usr/local/bin/cleanup.sh

Solution

  1. Step 1: Understand the syntax for every 15 minutes

    The */15 in the minute field means every 15 minutes.
  2. Step 2: Compare options

    */15 * * * * /usr/local/bin/cleanup.sh uses */15, which is the standard way to run every 15 minutes. 0,15,30 * * * * /usr/local/bin/cleanup.sh lists minutes explicitly but misses 45. 15 * * * * /usr/local/bin/cleanup.sh runs only at minute 15 each hour. 0-15 * * * * /usr/local/bin/cleanup.sh runs minutes 0 to 15 every hour, not every 15 minutes.
  3. Final Answer:

    */15 * * * * /usr/local/bin/cleanup.sh -> Option A
  4. Quick Check:

    Every 15 minutes = */15 in minute field [OK]
Hint: Use */15 in minute field for every 15 minutes [OK]
Common Mistakes:
  • Using single minute value instead of interval
  • Listing minutes but missing some intervals
  • Using range instead of step syntax
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard