forked from linux/documentation
1.6 KiB
1.6 KiB
Systemd Timers for Regular Tasks
Create New Timer
To have custom executables run regularly on given time/interval, you may use the base::timers Hiera key:
base::timers:
'timer_test':
description: 'test timers'
command: '/usr/bin/logger foo'
on_calendar: '*:*:10'
timer_options:
persistence: false
service_options:
Environment: 'SOME_ENV=some_value'
User: 'svcusr-logger'
service_unit_options:
OnSuccess: 'dnf-automatic'
OnFailure: 'send-failure-email'
This then creates both the required timer and service unit files for systemd.
For each timer following keys are mandatory
descriptionfor a short explanation what it is aboutcommandfor the command to runon_calendardefining when it should run using thesystemdcalendar event format, (alternatively see also chapter "CALENDAR EVENTS" ofman systemd.date)
Optional is
timer_optionsfor additional configuration in theTimersection of the timer unit. In the example it ispersistencewhich signals if the timer should run immediately after boot when the node was switched of on the last scheduled run time (default isfalse).service_optionsfor additional configuration in theServicesection of the service unit.service_unit_optionsfor additional options in theUnitsection of the service unit.
Enable/Disable Existing Timer
base::timers:
'certbot':
enable: true