0
0
Raspberry Piprogramming~20 mins

Cron jobs for scheduled tasks in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cron Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this cron schedule expression?
Given the cron schedule expression 30 14 * * 1-5, when will the cron job run?
AAt 2:30 PM every Saturday and Sunday
BAt 2:30 PM every weekday (Monday to Friday)
CAt 2:30 AM every day
DAt 14:00 every weekday (Monday to Friday)
Attempts:
2 left
💡 Hint
Remember, the fields are: minute, hour, day of month, month, day of week.
Predict Output
intermediate
1:30remaining
What will this cron job output?
A cron job runs the command echo $(date +"%H:%M") > /home/pi/time.txt every hour at minute 0. What will be the content of time.txt after the job runs at 3 PM?
A15:00
B03:00
C3 PM
DThe current date and time in full
Attempts:
2 left
💡 Hint
The format string %H:%M gives hour in 24-hour format and minutes.
🔧 Debug
advanced
2:00remaining
Why does this cron job not run?
A user added this line to their crontab: 0 9 * * * /home/pi/myscript.sh. The script has execute permission and runs fine manually. But the cron job never runs. What is the most likely reason?
AThe script path is incorrect or missing environment variables in cron
BThe cron job syntax is invalid
CThe script does not have execute permission
DThe cron daemon is not installed on Raspberry Pi
Attempts:
2 left
💡 Hint
Cron jobs run with a limited environment and may not have the same PATH as your user.
🧠 Conceptual
advanced
1:30remaining
How to schedule a cron job to run every 15 minutes?
Which cron schedule expression correctly runs a job every 15 minutes?
A0,15,30,45 * * * *
B15 * * * *
C*/15 * * * *
D0-15 * * * *
Attempts:
2 left
💡 Hint
The slash (/) operator in cron means 'every'.
📝 Syntax
expert
1:30remaining
What error does this crontab line cause?
Consider this crontab line: 0 25 * * * /home/pi/script.sh. What happens when cron tries to run this?
AThe cron daemon ignores the line and runs other jobs
BThe job runs at 1 AM (25 mod 24)
CThe job runs at midnight
DThe cron job will not run because hour 25 is invalid
Attempts:
2 left
💡 Hint
Hours in cron must be between 0 and 23.