How do you configure a systemd timer to run a job every day at 2am?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

How do you configure a systemd timer to run a job every day at 2am?

Explanation:
Systemd timers schedule a service by using the OnCalendar directive in the timer unit. To run a job every day at 2:00 a.m., you express a daily time by using a calendar spec like the wildcard date pattern with a specific time, for example: OnCalendar=*-*-* 02:00:00. That means every year, every month, every day at 02:00:00, which is 2 a.m. in the system’s local timezone. Pair this timer with the corresponding service unit that defines the actual job, and then enable and start the timer so it begins triggering immediately. The common, straightforward way is: set OnCalendar=*-*-* 02:00:00 in your timer, then run systemctl enable --now myjob.timer, and finally you can verify with systemctl status myjob.timer to confirm the timer is active and scheduled for the next run. Useful context: OnCalendar supports many forms, including simpler daily expressions, but the explicit year-month-day wildcards with a time give a clear, unambiguous daily schedule. Also remember that the timer will fire according to the system time, so the timezone of the host affects what “2 a.m.” means locally.

Systemd timers schedule a service by using the OnCalendar directive in the timer unit. To run a job every day at 2:00 a.m., you express a daily time by using a calendar spec like the wildcard date pattern with a specific time, for example: OnCalendar=--* 02:00:00. That means every year, every month, every day at 02:00:00, which is 2 a.m. in the system’s local timezone.

Pair this timer with the corresponding service unit that defines the actual job, and then enable and start the timer so it begins triggering immediately. The common, straightforward way is: set OnCalendar=--* 02:00:00 in your timer, then run systemctl enable --now myjob.timer, and finally you can verify with systemctl status myjob.timer to confirm the timer is active and scheduled for the next run.

Useful context: OnCalendar supports many forms, including simpler daily expressions, but the explicit year-month-day wildcards with a time give a clear, unambiguous daily schedule. Also remember that the timer will fire according to the system time, so the timezone of the host affects what “2 a.m.” means locally.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy