1SYSTEMD.TIMER(5)                 systemd.timer                SYSTEMD.TIMER(5)
2
3
4

NAME

6       systemd.timer - Timer unit configuration
7

SYNOPSIS

9       timer.timer
10

DESCRIPTION

12       A unit configuration file whose name ends in ".timer" encodes
13       information about a timer controlled and supervised by systemd, for
14       timer-based activation.
15
16       This man page lists the configuration options specific to this unit
17       type. See systemd.unit(5) for the common options of all unit
18       configuration files. The common configuration items are configured in
19       the generic "[Unit]" and "[Install]" sections. The timer specific
20       configuration options are configured in the "[Timer]" section.
21
22       For each timer file, a matching unit file must exist, describing the
23       unit to activate when the timer elapses. By default, a service by the
24       same name as the timer (except for the suffix) is activated. Example: a
25       timer file foo.timer activates a matching service foo.service. The unit
26       to activate may be controlled by Unit= (see below).
27
28       Note that in case the unit to activate is already active at the time
29       the timer elapses it is not restarted, but simply left running. There
30       is no concept of spawning new service instances in this case. Due to
31       this, services with RemainAfterExit= set (which stay around
32       continuously even after the service's main process exited) are usually
33       not suitable for activation via repetitive timers, as they will only be
34       activated once, and then stay around forever.
35

AUTOMATIC DEPENDENCIES

37   Implicit Dependencies
38       The following dependencies are implicitly added:
39
40       ·   Timer units automatically gain a Before= dependency on the service
41           they are supposed to activate.
42
43   Default Dependencies
44       The following dependencies are added unless DefaultDependencies=no is
45       set:
46
47       ·   Timer units will automatically have dependencies of type Requires=
48           and After= on sysinit.target, a dependency of type Before= on
49           timers.target, as well as Conflicts= and Before= on shutdown.target
50           to ensure that they are stopped cleanly prior to system shutdown.
51           Only timer units involved with early boot or late system shutdown
52           should disable the DefaultDependencies= option.
53
54       ·   Timer units with at least one OnCalendar= directive will have an
55           additional After= dependency on time-sync.target to avoid being
56           started before the system clock has been correctly set.
57

OPTIONS

59       Timer files must include a [Timer] section, which carries information
60       about the timer it defines. The options specific to the [Timer] section
61       of timer units are the following:
62
63       OnActiveSec=, OnBootSec=, OnStartupSec=, OnUnitActiveSec=,
64       OnUnitInactiveSec=
65           Defines monotonic timers relative to different starting points:
66
67           Table 1. Settings and their starting points
68           ┌───────────────────┬────────────────────────────┐
69Setting            Meaning                    
70           ├───────────────────┼────────────────────────────┤
71OnActiveSec=       │ Defines a timer relative   │
72           │                   │ to the moment the timer    │
73           │                   │ unit itself is activated.  │
74           ├───────────────────┼────────────────────────────┤
75OnBootSec=         │ Defines a timer relative   │
76           │                   │ to when the machine was    │
77           │                   │ booted up. In containers,  │
78           │                   │ for the system manager     │
79           │                   │ instance, this is mapped   │
80           │                   │ to OnStartupSec=, making   │
81           │                   │ both equivalent.           │
82           ├───────────────────┼────────────────────────────┤
83OnStartupSec=      │ Defines a timer relative   │
84           │                   │ to when the service        │
85           │                   │ manager was first started. │
86           │                   │ For system timer units     │
87           │                   │ this is very similar to    │
88           │                   │ OnBootSec= as the system   │
89           │                   │ service manager is         │
90           │                   │ generally started very     │
91           │                   │ early at boot. It's        │
92           │                   │ primarily useful when      │
93           │                   │ configured in units        │
94           │                   │ running in the per-user    │
95           │                   │ service manager, as the    │
96           │                   │ user service manager is    │
97           │                   │ generally started on first │
98           │                   │ login only, not already    │
99           │                   │ during boot.               │
100           ├───────────────────┼────────────────────────────┤
101OnUnitActiveSec=   │ Defines a timer relative   │
102           │                   │ to when the unit the timer │
103           │                   │ unit is activating was     │
104           │                   │ last activated.            │
105           ├───────────────────┼────────────────────────────┤
106OnUnitInactiveSec= │ Defines a timer relative   │
107           │                   │ to when the unit the timer │
108           │                   │ unit is activating was     │
109           │                   │ last deactivated.          │
110           └───────────────────┴────────────────────────────┘
111           Multiple directives may be combined of the same and of different
112           types, in which case the timer unit will trigger whenever any of
113           the specified timer expressions elapse. For example, by combining
114           OnBootSec= and OnUnitActiveSec=, it is possible to define a timer
115           that elapses in regular intervals and activates a specific service
116           each time. Moreover, both monotonic time expressions and
117           OnCalendar= calendar expressions may be combined in the same timer
118           unit.
119
120           The arguments to the directives are time spans configured in
121           seconds. Example: "OnBootSec=50" means 50s after boot-up. The
122           argument may also include time units. Example: "OnBootSec=5h 30min"
123           means 5 hours and 30 minutes after boot-up. For details about the
124           syntax of time spans, see systemd.time(7).
125
126           If a timer configured with OnBootSec= or OnStartupSec= is already
127           in the past when the timer unit is activated, it will immediately
128           elapse and the configured unit is started. This is not the case for
129           timers defined in the other directives.
130
131           These are monotonic timers, independent of wall-clock time and
132           timezones. If the computer is temporarily suspended, the monotonic
133           clock generally pauses, too. Note that if WakeSystem= is used, a
134           different monotonic clock is selected that continues to advance
135           while the system is suspended and thus can be used as the trigger
136           to resume the system.
137
138           If the empty string is assigned to any of these options, the list
139           of timers is reset (both monotonic timers and OnCalendar= timers,
140           see below), and all prior assignments will have no effect.
141
142           Note that timers do not necessarily expire at the precise time
143           configured with these settings, as they are subject to the
144           AccuracySec= setting below.
145
146       OnCalendar=
147           Defines realtime (i.e. wallclock) timers with calendar event
148           expressions. See systemd.time(7) for more information on the syntax
149           of calendar event expressions. Otherwise, the semantics are similar
150           to OnActiveSec= and related settings.
151
152           Note that timers do not necessarily expire at the precise time
153           configured with this setting, as it is subject to the AccuracySec=
154           setting below.
155
156           May be specified more than once, in which case the timer unit will
157           trigger whenever any of the specified expressions elapse. Moreover
158           calendar timers and monotonic timers (see above) may be combined
159           within the same timer unit.
160
161           If the empty string is assigned to any of these options, the list
162           of timers is reset (both OnCalendar= timers and monotonic timers,
163           see above), and all prior assignments will have no effect.
164
165       AccuracySec=
166           Specify the accuracy the timer shall elapse with. Defaults to 1min.
167           The timer is scheduled to elapse within a time window starting with
168           the time specified in OnCalendar=, OnActiveSec=, OnBootSec=,
169           OnStartupSec=, OnUnitActiveSec= or OnUnitInactiveSec= and ending
170           the time configured with AccuracySec= later. Within this time
171           window, the expiry time will be placed at a host-specific,
172           randomized, but stable position that is synchronized between all
173           local timer units. This is done in order to optimize power
174           consumption to suppress unnecessary CPU wake-ups. To get best
175           accuracy, set this option to 1us. Note that the timer is still
176           subject to the timer slack configured via systemd-system.conf(5)'s
177           TimerSlackNSec= setting. See prctl(2) for details. To optimize
178           power consumption, make sure to set this value as high as possible
179           and as low as necessary.
180
181           Note that this setting is primarily a power saving option that
182           allows coalescing CPU wake-ups. It should not be confused with
183           RandomizedDelaySec= (see below) which adds a random value to the
184           time the timer shall elapse next and whose purpose is the opposite:
185           to stretch elapsing of timer events over a longer period to reduce
186           workload spikes. For further details and explanations and how both
187           settings play together, see below.
188
189       RandomizedDelaySec=
190           Delay the timer by a randomly selected, evenly distributed amount
191           of time between 0 and the specified time value. Defaults to 0,
192           indicating that no randomized delay shall be applied. Each timer
193           unit will determine this delay randomly before each iteration, and
194           the delay will simply be added on top of the next determined
195           elapsing time. This is useful to stretch dispatching of similarly
196           configured timer events over a certain amount time, to avoid that
197           they all fire at the same time, possibly resulting in resource
198           congestion. Note the relation to AccuracySec= above: the latter
199           allows the service manager to coalesce timer events within a
200           specified time range in order to minimize wakeups, the former does
201           the opposite: it stretches timer events over a time range, to make
202           it unlikely that they fire simultaneously. If RandomizedDelaySec=
203           and AccuracySec= are used in conjunction, first the randomized
204           delay is added, and then the result is possibly further shifted to
205           coalesce it with other timer events happening on the system. As
206           mentioned above AccuracySec= defaults to 1min and
207           RandomizedDelaySec= to 0, thus encouraging coalescing of timer
208           events. In order to optimally stretch timer events over a certain
209           range of time, make sure to set RandomizedDelaySec= to a higher
210           value, and AccuracySec=1us.
211
212       OnClockChange=, OnTimezoneChange=
213           These options take boolean arguments. When true, the service unit
214           will be triggered when the system clock (CLOCK_REALTIME) jumps
215           relative to the monotonic clock (CLOCK_MONOTONIC), or when the
216           local system timezone is modified. These options can be used alone
217           or in combination with other timer expressions (see above) within
218           the same timer unit. These options default to false.
219
220       Unit=
221           The unit to activate when this timer elapses. The argument is a
222           unit name, whose suffix is not ".timer". If not specified, this
223           value defaults to a service that has the same name as the timer
224           unit, except for the suffix. (See above.) It is recommended that
225           the unit name that is activated and the unit name of the timer unit
226           are named identically, except for the suffix.
227
228       Persistent=
229           Takes a boolean argument. If true, the time when the service unit
230           was last triggered is stored on disk. When the timer is activated,
231           the service unit is triggered immediately if it would have been
232           triggered at least once during the time when the timer was
233           inactive. This is useful to catch up on missed runs of the service
234           when the system was powered down. Note that this setting only has
235           an effect on timers configured with OnCalendar=. Defaults to false.
236
237           Use systemctl clean --what=state ...  on the timer unit to remove
238           the timestamp file maintained by this option from disk. In
239           particular, use this command before uninstalling a timer unit. See
240           systemctl(1) for details.
241
242       WakeSystem=
243           Takes a boolean argument. If true, an elapsing timer will cause the
244           system to resume from suspend, should it be suspended and if the
245           system supports this. Note that this option will only make sure the
246           system resumes on the appropriate times, it will not take care of
247           suspending it again after any work that is to be done is finished.
248           Defaults to false.
249
250           Note that this functionality requires privileges and is thus
251           generally only available in the system service manager.
252
253           Note that behaviour of monotonic clock timers (as configured with
254           OnActiveSec=, OnBootSec=, OnStartupSec=, OnUnitActiveSec=,
255           OnUnitInactiveSec=, see above) is altered depending on this option.
256           If false, a monotonic clock is used that is paused during system
257           suspend (CLOCK_MONOTONIC), if true a different monotonic clock is
258           used that continues advancing during system suspend
259           (CLOCK_BOOTTIME), see clock_getres(2) for details.
260
261       RemainAfterElapse=
262           Takes a boolean argument. If true, an elapsed timer will stay
263           loaded, and its state remains queryable. If false, an elapsed timer
264           unit that cannot elapse anymore is unloaded. Turning this off is
265           particularly useful for transient timer units that shall disappear
266           after they first elapse. Note that this setting has an effect on
267           repeatedly starting a timer unit that only elapses once: if
268           RemainAfterElapse= is on, it will not be started again, and is
269           guaranteed to elapse only once. However, if RemainAfterElapse= is
270           off, it might be started again if it is already elapsed, and thus
271           be triggered multiple times. Defaults to yes.
272

SEE ALSO

274       systemd(1), systemctl(1), systemd.unit(5), systemd.service(5),
275       systemd.time(7), systemd.directives(7), systemd-system.conf(5),
276       prctl(2)
277
278
279
280systemd 245                                                   SYSTEMD.TIMER(5)
Impressum