0
0
Linux CLIscripting~20 mins

crontab syntax in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Crontab Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this crontab entry?
Given the crontab line below, what time(s) will the command run?

30 2 * * 1 /usr/bin/backup.sh
Linux CLI
30 2 * * 1 /usr/bin/backup.sh
ARuns every Monday at 2:30 AM
BRuns every day at 2:30 AM
CRuns every Monday at 12:30 PM
DRuns every day at 12:30 PM
Attempts:
2 left
💡 Hint
Remember the order: minute, hour, day of month, month, day of week.
💻 Command Output
intermediate
1:30remaining
What does this crontab entry do?
What is the effect of this crontab line?

0 */4 * * * /usr/bin/cleanup.sh
Linux CLI
0 */4 * * * /usr/bin/cleanup.sh
ARuns every 4 hours at the start of the hour
BRuns every 4 minutes
CRuns every 4 days at midnight
DRuns every day at 4 AM
Attempts:
2 left
💡 Hint
The hour field uses '*/4' which means every 4 hours.
📝 Syntax
advanced
2:00remaining
Which crontab entry runs a command every weekday at 6:15 PM?
Select the correct crontab line to run a script at 6:15 PM Monday through Friday.
A15 6 * * 1-5 /usr/bin/script.sh
B18 15 * * 1-5 /usr/bin/script.sh
C15 18 * * 1-5 /usr/bin/script.sh
D15 18 * * 0-6 /usr/bin/script.sh
Attempts:
2 left
💡 Hint
Remember the order: minute, hour, day of month, month, day of week.
🔧 Debug
advanced
2:00remaining
Why does this crontab entry not run at midnight as expected?
A user wants to run a script at midnight every day but wrote:

0 24 * * * /usr/bin/midnight.sh

What is the problem?
AMinute field cannot be 0
BHour field '24' is invalid; valid range is 0-23
CDay of month field is missing
DCommand path is incorrect
Attempts:
2 left
💡 Hint
Check the valid ranges for hour in crontab.
🚀 Application
expert
3:00remaining
How many times will this crontab entry run in a week?
Given this crontab line:

*/15 9-17 * * 1-5 /usr/bin/task.sh

How many times does the command run in one week?
A240 times
B200 times
C160 times
D180 times
Attempts:
2 left
💡 Hint
Calculate runs per hour, hours per day, and days per week.