A systemd timer is a tool in Linux that schedules tasks to run automatically at specific times or intervals, similar to a clock alarm for scripts or commands.
Click to reveal answer
beginner
Which two files are needed to create a systemd timer?
You need a .service file that defines the task to run, and a .timer file that schedules when the task runs.
Click to reveal answer
beginner
How do you start and enable a systemd timer named backup.timer?
Use sudo systemctl start backup.timer to start it now, and sudo systemctl enable backup.timer to make it start automatically on boot.
Click to reveal answer
intermediate
What does the OnCalendar= setting do in a systemd timer file?
It sets the schedule for when the timer triggers, using calendar events like daily, weekly, or specific dates and times.
Click to reveal answer
beginner
How can you check the status and last run time of a systemd timer?
Run systemctl status yourtimer.timer to see if it is active and when it last triggered.
Click to reveal answer
What file extension does a systemd timer unit use?
A.sched
B.service
C.timerunit
D.timer
✗ Incorrect
Systemd timer units always use the .timer extension.
Which command starts a systemd timer immediately?
Asystemctl start timer.timer
Bsystemctl start timer.service
Csystemctl enable timer.timer
Dsystemctl run timer.timer
✗ Incorrect
You start the timer unit with 'systemctl start timer.timer'.
What does the OnBootSec= option do in a timer file?
ARuns the task a set number of seconds after boot
BRuns the task at a fixed time daily
CRuns the task every second
DDisables the timer
✗ Incorrect
OnBootSec= schedules the task to run after a delay from system boot.
If you want a task to run every 10 minutes, which timer setting is best?
AOnCalendar=hourly
BOnUnitActiveSec=10min
COnCalendar=daily
DOnBootSec=10min
✗ Incorrect
OnUnitActiveSec=10min triggers the task 10 minutes after the last run.
How do you check when a systemd timer last triggered?
Ajournalctl -u timer.timer
Bsystemctl status timer.service
Csystemctl status timer.timer
Dcat /var/log/timer.log
✗ Incorrect
The status command on the timer unit shows last trigger time.
Explain how to create and enable a systemd timer to run a backup script every day at 2 AM.
Think about two files and scheduling with OnCalendar.
You got /4 concepts.
Describe how systemd timers differ from cron jobs and one advantage of using timers.
Focus on management and features differences.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a systemd timer in Linux?
easy
A. To manage user permissions
B. To schedule and run tasks automatically at specified times
C. To monitor system hardware status
D. To update software packages automatically
Solution
Step 1: Understand systemd timer role
Systemd timers are designed to schedule tasks to run automatically without manual intervention.
Step 2: Compare with other options
Monitoring hardware, managing permissions, and updating packages are not the primary roles of systemd timers.
Final Answer:
To schedule and run tasks automatically at specified times -> Option B
Quick Check:
Systemd timers = schedule tasks [OK]
Hint: Timers schedule tasks like alarms for programs [OK]
Common Mistakes:
Confusing timers with monitoring tools
Thinking timers manage user permissions
Assuming timers update software automatically
2. Which of the following is the correct syntax to enable a systemd timer named backup.timer?
easy
A. systemctl enable backup.timer
B. systemctl start backup.timer
C. systemctl run backup.timer
D. systemctl activate backup.timer
Solution
Step 1: Identify enabling command for systemd timers
The command systemctl enable sets a timer to start automatically on boot.
Step 2: Differentiate from other commands
start runs the timer immediately but does not enable it; run and activate are invalid commands.
Final Answer:
systemctl enable backup.timer -> Option A
Quick Check:
Enable timer = systemctl enable [OK]
Hint: Use 'enable' to start timer on boot, 'start' to run now [OK]
Common Mistakes:
Using 'start' instead of 'enable' to auto-run timers
Using invalid commands like 'run' or 'activate'
Confusing service commands with timer commands
3. Given this timer unit file snippet:
[Timer]
OnCalendar=*-*-* 12:00:00
Persistent=true
What does the Persistent=true setting do?
medium
A. Prevents the timer from running at boot
B. Runs the timer only once
C. Disables the timer after one run
D. Runs missed jobs immediately after boot
Solution
Step 1: Understand Persistent=true meaning
This setting makes systemd run any missed timer jobs immediately after the system boots.
Step 2: Eliminate other options
It does not limit runs to once, disable timers, or prevent running at boot.
Final Answer:
Runs missed jobs immediately after boot -> Option D
Quick Check:
Persistent=true = catch missed runs after reboot [OK]
Hint: Persistent=true runs missed tasks after reboot [OK]
Common Mistakes:
Thinking it runs only once
Assuming it disables timer after run
Believing it prevents timer at boot
4. You created a timer file cleanup.timer but it never triggers the service. Which is the most likely mistake?
medium
A. The timer file is not named exactly like the service file
B. The timer file is missing the [Timer] section
C. The service file cleanup.service is not enabled
D. The timer file uses OnBootSec= instead of OnCalendar=
Solution
Step 1: Check timer and service file naming
Systemd timers must have matching names with their service files except for the extension.
Step 2: Analyze other options
Missing [Timer] section causes syntax errors; service enabling is not required for timers to trigger; both OnBootSec and OnCalendar are valid.
Final Answer:
The timer file is not named exactly like the service file -> Option A
Quick Check:
Timer and service names must match [OK]
Hint: Timer and service filenames must match except extension [OK]
Common Mistakes:
Ignoring filename matching between timer and service
Assuming service must be enabled for timer to run
Confusing valid timer options as errors
5. You want a systemd timer to run a backup service every day at 3:30 AM but only if the system was off at that time. Which timer configuration achieves this?
hard
A. [Timer]
OnActiveSec=03:30:00
Persistent=true
B. [Timer]
OnCalendar=*-*-* 03:30:00
AccuracySec=1min
C. [Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true
D. [Timer]
OnBootSec=03:30:00
Persistent=false
Solution
Step 1: Identify daily schedule at 3:30 AM
The OnCalendar=*-*-* 03:30:00 sets the timer to run daily at 3:30 AM.
Step 2: Ensure missed runs execute after downtime
Persistent=true makes systemd run missed jobs after system was off at scheduled time.
Step 3: Evaluate other options
AccuracySec adjusts timing precision but doesn't affect missed runs; OnBootSec and OnActiveSec run relative to boot or activation, not fixed time.
Final Answer:
[Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true -> Option C
Quick Check:
Daily 3:30 AM with catch-up = OnCalendar + Persistent [OK]
Hint: Use OnCalendar with Persistent=true for daily missed runs [OK]
Common Mistakes:
Using OnBootSec instead of OnCalendar for fixed time
Forgetting Persistent=true to run missed jobs
Confusing AccuracySec with scheduling behavior
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.