0
0
Raspberry Piprogramming~5 mins

Cron jobs for scheduled tasks in Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a cron job?
A cron job is a scheduled task that runs automatically at set times or intervals on a Raspberry Pi or other Linux systems.
Click to reveal answer
beginner
How do you edit the cron jobs for the current user?
You use the command crontab -e to open the cron table editor for the current user.
Click to reveal answer
intermediate
What does the cron time format look like?
It has five fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-7, Sunday=0 or 7). Each field controls when the task runs.
Click to reveal answer
intermediate
How would you schedule a script to run every day at 7:30 AM?
You write this in crontab: 30 7 * * * /path/to/script.sh. This means at minute 30, hour 7, every day, every month, every day of the week.
Click to reveal answer
intermediate
Why is it important to use full paths in cron jobs?
Because cron runs with a limited environment, using full paths ensures the system finds the commands and scripts correctly.
Click to reveal answer
Which command opens the cron editor for the current user?
Acronedit
Beditcron
Ccron -open
Dcrontab -e
In a cron schedule, what does the '*' symbol mean?
ASkip this field
BEvery possible value for that field
COnly once
DNo value
How often will this cron job run? 0 0 * * 0 /home/pi/script.sh
AEvery Sunday at midnight
BEvery day at midnight
CEvery hour on Sunday
DEvery minute on Sunday
Why should you use full paths in cron commands?
ABecause cron has a limited environment and may not find commands without full paths
BTo make the command shorter
CTo make the command run faster
DIt is not necessary to use full paths
What does the following cron time mean? */15 * * * *
AEvery 15 days
BEvery 15 hours
CEvery 15 minutes
DEvery 15 seconds
Explain how to create a cron job that runs a backup script every day at 2 AM on a Raspberry Pi.
Think about the time fields and how to edit the cron table.
You got /5 concepts.
    Describe why cron jobs might fail if you do not use full paths or environment variables.
    Consider what environment cron runs in compared to your normal terminal.
    You got /5 concepts.