Bird
Raised Fist0
Linux CLIscripting~20 mins

Common cron expressions in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Cron Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this cron expression schedule?
Given the cron expression 0 0 * * 0, what does it schedule?
ARuns the job every Sunday at midnight
BRuns the job every day at midnight
CRuns the job every hour on Sundays
DRuns the job every Sunday at noon
Attempts:
2 left
💡 Hint
Remember the fields: minute, hour, day of month, month, day of week.
💻 Command Output
intermediate
2:00remaining
What does this cron expression do?
What is the schedule for the cron expression */15 9-17 * * 1-5?
ARuns every 15 minutes from 9 AM to 5 PM on weekends
BRuns every 15 minutes all day on weekdays
CRuns every 15 minutes from 9 AM to 5 PM, Monday to Friday
DRuns every 15 minutes from 9 AM to 5 PM every day
Attempts:
2 left
💡 Hint
Look at the hour and day of week fields carefully.
💻 Command Output
advanced
2:00remaining
What is the output of this cron expression?
What schedule does the cron expression 30 23 1 * * represent?
ARuns at 11:30 PM on the first day of every month
BRuns at 11:30 AM on the first day of every month
CRuns at 11:30 PM every day
DRuns at 11:30 PM on the first Monday of every month
Attempts:
2 left
💡 Hint
Check the day of month and hour fields.
💻 Command Output
advanced
2:00remaining
What error or output does this cron expression produce?
What happens if you use the cron expression 60 24 * * *?
ARuns at midnight every day
BRuns at 24:00 every day (valid time)
CRuns at 00:00 on the 60th day of the month
DIt causes an error because 60 is invalid for minutes
Attempts:
2 left
💡 Hint
Minutes range from 0 to 59, hours from 0 to 23.
🧠 Conceptual
expert
2:00remaining
How many times does this cron expression run in a week?
How many times will the job run with the cron expression 0 12 */2 * 1 in one week?
A4 times
B3 times
C1 time
D0 times
Attempts:
2 left
💡 Hint
Cron uses OR logic for day of month and day of week fields interaction.

Practice

(1/5)
1. What does the cron expression 0 0 * * * do?
easy
A. Runs a task every minute
B. Runs a task every hour
C. Runs a task every day at midnight
D. Runs a task every Sunday at midnight

Solution

  1. Step 1: Understand the cron fields

    The expression has five fields: minute=0, hour=0, day=*, month=*, weekday=*. This means minute 0, hour 0, every day, every month, every weekday.
  2. Step 2: Interpret the schedule

    Since minute and hour are fixed at 0, and others are '*', the task runs once daily at 00:00 (midnight).
  3. Final Answer:

    Runs a task every day at midnight -> Option C
  4. Quick Check:

    0 0 * * * = daily at midnight [OK]
Hint: Minute and hour 0 means daily at midnight [OK]
Common Mistakes:
  • Thinking * means no schedule
  • Confusing hour and minute fields
  • Assuming it runs every minute
2. Which of the following is the correct cron syntax to run a job every 15 minutes?
easy
A. 15 * * * *
B. */15 * * * *
C. * 15 * * *
D. 0 */15 * * *

Solution

  1. Step 1: Understand the minute field syntax

    Using '*/15' in the minute field means every 15 minutes (0,15,30,45).
  2. Step 2: Check other fields

    All other fields are '*', meaning every hour, day, month, and weekday.
  3. Final Answer:

    */15 * * * * -> Option B
  4. Quick Check:

    */15 in minutes means every 15 minutes [OK]
Hint: */15 in minute field means every 15 minutes [OK]
Common Mistakes:
  • Using 15 in minute field runs only at minute 15
  • Putting 15 in hour field runs at 3 PM only
  • Using 0 */15 runs every 15 hours, not minutes
3. What is the output behavior of this cron expression: 30 6 * * 1?
medium
A. Runs at 6:30 AM every Monday
B. Runs at 6:30 AM every day
C. Runs at 6:00 AM every Monday
D. Runs every minute on Mondays

Solution

  1. Step 1: Analyze the fields

    Minute=30, Hour=6, Day=*, Month=*, Weekday=1 (Monday).
  2. Step 2: Interpret the schedule

    The task runs at 6:30 AM only on Mondays.
  3. Final Answer:

    Runs at 6:30 AM every Monday -> Option A
  4. Quick Check:

    30 6 * * 1 = Monday 6:30 AM [OK]
Hint: Weekday 1 means Monday, time 6:30 is hour:minute [OK]
Common Mistakes:
  • Confusing weekday with day of month
  • Assuming it runs daily instead of weekly
  • Mixing hour and minute fields
4. Identify the error in this cron expression: 60 24 * * *
medium
A. Minute value 60 is invalid
B. Hour value 24 is invalid
C. No error, this is valid syntax
D. Both minute and hour values are invalid

Solution

  1. Step 1: Check minute field validity

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

    Hour field must be 0-23; 24 is invalid.
  3. Final Answer:

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

    Minute max 59, hour max 23 [OK]
Hint: Minutes max 59, hours max 23 in cron [OK]
Common Mistakes:
  • Assuming 60 is valid minute
  • Assuming 24 is valid hour
  • Thinking cron allows 24:00 time
5. You want to schedule a backup script to run at 2:15 AM on the 1st day of every month. Which cron expression should you use?
hard
A. 15 2 1 * *
B. 2 15 1 * *
C. 15 2 * * 1
D. 0 2 15 * *

Solution

  1. Step 1: Map time and date to cron fields

    Minute=15, Hour=2, Day=1 (first day), Month=*, Weekday=* (any day).
  2. Step 2: Verify expression correctness

    Expression '15 2 1 * *' matches 2:15 AM on day 1 of every month.
  3. Final Answer:

    15 2 1 * * -> Option A
  4. Quick Check:

    Minute=15, Hour=2, Day=1 means 2:15 AM on 1st [OK]
Hint: Minute Hour Day Month Weekday order in cron [OK]
Common Mistakes:
  • Swapping hour and minute fields
  • Using weekday instead of day of month
  • Setting wrong day or time values
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