What is the purpose of the crontab command in Linux?
The crontab command is used to schedule tasks (called cron jobs) to run automatically at specified times or intervals.
Click to reveal answer
beginner
In crontab syntax, what does the asterisk (*) symbol mean?
The asterisk (*) means "every" possible value for that time field. For example, * in the minute field means every minute.
Click to reveal answer
beginner
Explain the five time fields in a crontab entry.
The five time fields are: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-7, where 0 and 7 both mean Sunday). They define when the command runs.
Click to reveal answer
intermediate
How do you schedule a cron job to run every 5 minutes?
Use */5 in the minute field, like: */5 * * * *. This means every 5 minutes, every hour, every day, every month, every weekday.
Click to reveal answer
intermediate
What does this crontab line do? 0 0 1 * * /home/user/backup.sh
It runs the script /home/user/backup.sh at midnight (00:00) on the first day of every month.
Click to reveal answer
What does the following crontab time field mean? 30 14 * * *
ARun at 14:30 on the first day of every month
BRun every 30 minutes starting at 2 PM
CRun every minute between 2 PM and 3 PM
DRun at 2:30 PM every day
✗ Incorrect
The fields mean minute=30, hour=14 (2 PM), and the rest are wildcards meaning every day, month, and weekday.
Which symbol in crontab means 'every' value for a time field?
A#
B*
C/
D-
✗ Incorrect
The asterisk (*) means every possible value for that time field.
How do you specify a cron job to run only on Sundays?
ABoth A and B
B* * * * 7
C* * * * 1
D* * * * 0
✗ Incorrect
In crontab, both 0 and 7 represent Sunday in the day of week field.
What does this crontab entry do? 15 10 * * 1-5 /usr/bin/script.sh
ARuns script.sh at 10:15 AM Monday to Friday
BRuns script.sh at 10:15 AM every day
CRuns script.sh every minute from 10:00 to 10:15 on weekdays
DRuns script.sh at 10:15 AM on weekends
✗ Incorrect
The day of week field 1-5 means Monday to Friday.
Which crontab field controls the month when a job runs?
AFirst field
BSecond field
CFourth field
DFifth field
✗ Incorrect
The fourth field in crontab syntax is the month (1-12).
Describe the structure of a crontab entry and what each time field means.
Think about the order and range of each time field.
You got /6 concepts.
Explain how to schedule a cron job to run every day at 6:30 AM.
Use exact numbers for hour and minute, wildcards for others.
You got /4 concepts.
Practice
(1/5)
1. What does the asterisk (*) symbol mean in a crontab time field like * * * * *?
easy
A. It means 'run only on weekends'
B. It means 'no value' or 'skip this field'
C. It means 'only once at midnight'
D. It means 'every' possible value for that field
Solution
Step 1: Understand the asterisk in crontab
The asterisk (*) in crontab means to match every possible value for that time field, like every minute or every hour.
Step 2: Apply to the example
In * * * * *, each asterisk means every minute, every hour, every day, every month, and every weekday.
Final Answer:
It means 'every' possible value for that field -> Option D
Quick Check:
Asterisk = every value [OK]
Hint: Asterisk means 'every' in crontab fields [OK]
Common Mistakes:
Thinking * means 'no value' or skip
Confusing * with specific times
Assuming * means only weekends
2. Which of the following is the correct crontab syntax to run a script every day at 3:30 AM?
easy
A. 30 3 * * * /path/to/script.sh
B. 3 30 * * * /path/to/script.sh
C. * 3 30 * * /path/to/script.sh
D. 30 * 3 * * /path/to/script.sh
Solution
Step 1: Understand crontab field order
The fields are: minute, hour, day of month, month, day of week.
Step 2: Match time 3:30 AM
3:30 AM means minute=30, hour=3, so the first two fields must be 30 and 3 respectively.
Final Answer:
30 3 * * * /path/to/script.sh -> Option A
Quick Check:
Minute=30, Hour=3 correct [OK]
Hint: Minute is first, hour second in crontab [OK]
Common Mistakes:
Swapping hour and minute fields
Using day or month fields incorrectly
Misplacing asterisks
3. Given the crontab entry 15 14 1 * * running /usr/bin/backup.sh, when will the script run?