0
0
Raspberry Piprogramming~20 mins

Scheduled data collection with cron 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!
query_result
intermediate
1:30remaining
What is the output of this cron schedule?
Given the cron expression 30 2 * * 1-5, when will the scheduled task run?
AAt 2:30 AM every weekday (Monday to Friday)
BAt 2:30 PM every day
CAt 2:00 AM every Monday to Friday
DAt 30 minutes past every hour on weekdays
Attempts:
2 left
💡 Hint
Remember the order of fields in a cron expression: minute, hour, day of month, month, day of week.
📝 Syntax
intermediate
1:30remaining
Identify the syntax error in this cron job entry
Which option shows a syntax error in a cron job entry?
A0 25 * * * /home/pi/script.sh
B0 0 * * 0 /home/pi/script.sh
C15 14 1 * * /home/pi/script.sh
D*/10 * * * * /home/pi/script.sh
Attempts:
2 left
💡 Hint
Check the valid range for the hour field in cron.
optimization
advanced
2:00remaining
Optimize this cron schedule for hourly data collection
You want to collect data every hour at 15 minutes past the hour. Which cron expression is the most efficient and correct?
A*/15 * * * * /home/pi/collect_data.sh
B0 15 * * * /home/pi/collect_data.sh
C15 * * * * /home/pi/collect_data.sh
D15 0-23 * * * /home/pi/collect_data.sh
Attempts:
2 left
💡 Hint
Remember the order: minute, hour, day, month, weekday.
🔧 Debug
advanced
2:00remaining
Why does this cron job not run as expected?
A cron job entry is: 0 6 * * * /home/pi/data_collect.sh. The script runs fine manually but does not run at 6 AM. What is the most likely cause?
AThe script path is incorrect because cron uses a different working directory
BCron does not support running scripts at 6 AM
CThe cron daemon is not installed on Raspberry Pi
DThe script lacks execute permissions for the user running cron
Attempts:
2 left
💡 Hint
Check permissions and environment differences between manual and cron runs.
🧠 Conceptual
expert
3:00remaining
How to ensure data collection runs even if the previous run is still active?
You schedule a data collection script every 10 minutes with cron. Sometimes the script takes longer than 10 minutes. Which approach ensures no overlapping runs?
ARun multiple instances in parallel to speed up data collection
BUse a lock file in the script to check if a previous instance is running and exit if so
CRestart the Raspberry Pi before each scheduled run
DSchedule the cron job every 5 minutes instead of 10
Attempts:
2 left
💡 Hint
Think about how to prevent multiple script instances from running simultaneously.