0
0
Linux CLIscripting~20 mins

systemd timers in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Systemd Timer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of systemd timer status command
What is the output of the command systemctl status mytask.timer if the timer is active and scheduled to run the next job in 10 minutes?
Linux CLI
systemctl status mytask.timer
A
● mytask.timer - Run mytask periodically
   Loaded: loaded (/etc/systemd/system/mytask.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Fri 2024-06-21 10:00:00 UTC; 5min ago
   Trigger: Fri 2024-06-21 10:15:00 UTC; 10min left
B
● mytask.timer - Run mytask periodically
   Loaded: loaded (/etc/systemd/system/mytask.timer; disabled; vendor preset: enabled)
   Active: inactive (dead)
C
● mytask.timer - Run mytask periodically
   Loaded: loaded (/etc/systemd/system/mytask.timer; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2024-06-21 09:50:00 UTC; 15min ago
D
● mytask.timer - Run mytask periodically
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
Attempts:
2 left
💡 Hint
Look for the 'Active: active (waiting)' status and the next trigger time.
🧠 Conceptual
intermediate
2:00remaining
Understanding systemd timer units and service units
Which statement correctly describes the relationship between a systemd timer unit and its corresponding service unit?
ATimer units and service units are independent and do not interact.
BA service unit schedules the timer unit to run at specific times.
CA timer unit triggers the execution of its linked service unit according to the schedule defined in the timer.
DA timer unit replaces the need for a service unit entirely.
Attempts:
2 left
💡 Hint
Think about what triggers the service execution in systemd timers.
📝 Syntax
advanced
2:00remaining
Identify the correct OnCalendar syntax for a systemd timer
Which option correctly sets a systemd timer to run every day at 3:30 AM using the OnCalendar directive?
Linux CLI
[Timer]
OnCalendar=???
Adaily 03:30
B03:30 daily
Cdaily
D03:30:00
Attempts:
2 left
💡 Hint
OnCalendar uses a specific time format like 'HH:MM:SS' or calendar events.
🔧 Debug
advanced
2:00remaining
Why does this systemd timer not trigger the service?
Given the following timer unit file, why does the timer never trigger the service? [Unit] Description=Run backup daily [Timer] OnCalendar=daily Persistent=true [Install] WantedBy=timers.target
Linux CLI
[Service]
ExecStart=/usr/local/bin/backup.sh
AThe timer unit file is missing the [Service] section; the service is not defined here.
BThe OnCalendar=daily syntax is invalid and causes the timer to fail silently.
CThe Persistent=true option disables the timer from running if missed.
DThe WantedBy=timers.target is incorrect; it should be multi-user.target.
Attempts:
2 left
💡 Hint
Timers trigger service units, but the service unit must be defined separately.
🚀 Application
expert
3:00remaining
Create a systemd timer to run a script every 15 minutes starting at 5 minutes past the hour
Which OnCalendar value correctly schedules a systemd timer to run every 15 minutes starting at 5 minutes past each hour (e.g., 00:05, 00:20, 00:35, 00:50)?
AOnCalendar=*-*-* *:05,20,35,50:00
BOnCalendar=*-*-* *:05/15:00
COnCalendar=*-*-* *:5/15:00
DOnCalendar=*:05/15:00
Attempts:
2 left
💡 Hint
Use the format 'HH:MM/interval:SS' with leading zeros for minutes.