Debian Codegraph @

upstream/debian-unstable/man5/systemd.timer.5

raw
1 '\" t
2 .TH "SYSTEMD\&.TIMER" "5" "" "systemd 261~rc3" "systemd.timer"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd.timer \- Timer unit configuration
24 .SH "SYNOPSIS"
25 .PP
26 \fItimer\fR\&.timer
27 .SH "DESCRIPTION"
28 .PP
29 A unit configuration file whose name ends in
30 "\&.timer"
31 encodes information about a timer controlled and supervised by systemd, for timer\-based activation\&.
32 .PP
33 This man page lists the configuration options specific to this unit type\&. See
34 \fBsystemd.unit\fR(5)
35 for the common options of all unit configuration files\&. The common configuration items are configured in the generic [Unit] and [Install] sections\&. The timer specific configuration options are configured in the [Timer] section\&.
36 .PP
37 For each timer file, a matching unit file must exist, describing the unit to activate when the timer elapses\&. By default, a service by the same name as the timer (except for the suffix) is activated\&. Example: a timer file
38 foo\&.timer
39 activates a matching service
40 foo\&.service\&. The unit to activate may be controlled by
41 \fIUnit=\fR
42 (see below)\&.
43 .PP
44 Note that in case the unit to activate is already active at the time the timer elapses it is not restarted, but simply left running\&. There is no concept of spawning new service instances in this case\&. Due to this, services with
45 \fIRemainAfterExit=yes\fR
46 set (which stay around continuously even after the service\*(Aqs main process exited) are usually not suitable for activation via repetitive timers, as they will only be activated once, and then stay around forever\&. Target units, which by default do not deactivate on their own, can be activated repeatedly by timers by setting
47 \fIStopWhenUnneeded=yes\fR
48 on them\&. This will cause a target unit to be stopped immediately after its activation, if it is not a dependency of another running unit\&.
49 .SH "AUTOMATIC DEPENDENCIES"
50 .SS "Implicit Dependencies"
51 .PP
52 The following dependencies are implicitly added:
53 .sp
54 .RS 4
55 .ie n \{\
56 \h'-04'\(bu\h'+03'\c
57 .\}
58 .el \{\
59 .sp -1
60 .IP \(bu 2.3
61 .\}
62 Timer units automatically gain a
63 \fIBefore=\fR
64 dependency on the service they are supposed to activate\&.
65 .RE
66 .SS "Default Dependencies"
67 .PP
68 The following dependencies are added unless
69 \fIDefaultDependencies=no\fR
70 is set:
71 .sp
72 .RS 4
73 .ie n \{\
74 \h'-04'\(bu\h'+03'\c
75 .\}
76 .el \{\
77 .sp -1
78 .IP \(bu 2.3
79 .\}
80 Timer units will automatically have dependencies of type
81 \fIRequires=\fR
82 and
83 \fIAfter=\fR
84 on
85 sysinit\&.target, a dependency of type
86 \fIBefore=\fR
87 on
88 timers\&.target, as well as
89 \fIConflicts=\fR
90 and
91 \fIBefore=\fR
92 on
93 shutdown\&.target
94 to ensure that they are stopped cleanly prior to system shutdown\&. Only timer units involved with early boot or late system shutdown should disable the
95 \fIDefaultDependencies=\fR
96 option\&.
97 .RE
98 .sp
99 .RS 4
100 .ie n \{\
101 \h'-04'\(bu\h'+03'\c
102 .\}
103 .el \{\
104 .sp -1
105 .IP \(bu 2.3
106 .\}
107 Timer units with at least one
108 \fIOnCalendar=\fR
109 directive acquire a pair of additional
110 \fIAfter=\fR
111 dependencies on
112 time\-set\&.target
113 and
114 time\-sync\&.target, in order to avoid being started before the system clock has been correctly set\&. See
115 \fBsystemd.special\fR(7)
116 for details on these two targets\&.
117 .RE
118 .SH "OPTIONS"
119 .PP
120 Timer unit files may include [Unit] and [Install] sections, which are described in
121 \fBsystemd.unit\fR(5)\&.
122 .PP
123 Timer unit files must include a [Timer] section, which carries information about the timer it defines\&. The options specific to the [Timer] section of timer units are the following:
124 .PP
125 \fIOnActiveSec=\fR, \fIOnBootSec=\fR, \fIOnStartupSec=\fR, \fIOnUnitActiveSec=\fR, \fIOnUnitInactiveSec=\fR
126 .RS 4
127 Defines monotonic timers relative to different starting points:
128 .sp
129 .it 1 an-trap
130 .nr an-no-space-flag 1
131 .nr an-break-flag 1
132 .br
133 .B Table\ \&1.\ \&Settings and their starting points
134 .TS
135 allbox tab(:);
136 lB lB.
137 T{
138 Setting
139 T}:T{
140 Meaning
141 T}
142 .T&
143 l l
144 l l
145 l l
146 l l
147 l l.
148 T{
149 \fIOnActiveSec=\fR
150 T}:T{
151 Defines a timer relative to the moment the timer unit itself is activated\&.
152 T}
153 T{
154 \fIOnBootSec=\fR
155 T}:T{
156 Defines a timer relative to when the machine was booted up\&. In containers, for the system manager instance, this is mapped to \fIOnStartupSec=\fR, making both equivalent\&.
157 T}
158 T{
159 \fIOnStartupSec=\fR
160 T}:T{
161 Defines a timer relative to when the service manager was first started\&. For system timer units this is very similar to \fIOnBootSec=\fR as the system service manager is generally started very early at boot\&. It\*(Aqs primarily useful when configured in units running in the per\-user service manager, as the user service manager is generally started on first login only, not already during boot\&.
162 T}
163 T{
164 \fIOnUnitActiveSec=\fR
165 T}:T{
166 Defines a timer relative to when the unit the timer unit is activating was last activated\&.
167 T}
168 T{
169 \fIOnUnitInactiveSec=\fR
170 T}:T{
171 Defines a timer relative to when the unit the timer unit is activating was last deactivated\&.
172 T}
173 .TE
174 .sp 1
175 Multiple directives may be combined of the same and of different types, in which case the timer unit will trigger whenever any of the specified timer expressions elapse\&. For example, by combining
176 \fIOnBootSec=\fR
177 and
178 \fIOnUnitActiveSec=\fR, it is possible to define a timer that elapses in regular intervals and activates a specific service each time\&. Moreover, both monotonic time expressions and
179 \fIOnCalendar=\fR
180 calendar expressions may be combined in the same timer unit\&.
181 .sp
182 The arguments to the directives are time spans configured in seconds\&. Example: "OnBootSec=50" means 50s after boot\-up\&. The argument may also include time units\&. Example: "OnBootSec=5h 30min" means 5 hours and 30 minutes after boot\-up\&. For details about the syntax of time spans, see
183 \fBsystemd.time\fR(7)\&.
184 .sp
185 If a timer configured with
186 \fIOnBootSec=\fR
187 or
188 \fIOnStartupSec=\fR
189 is already in the past when the timer unit is activated, it will immediately elapse and the configured unit is started\&. This is not the case for timers defined in the other directives\&.
190 .sp
191 These are monotonic timers, independent of wall\-clock time and timezones\&. If the computer is temporarily suspended, the monotonic clock generally pauses, too\&. Note that if
192 \fIWakeSystem=\fR
193 is used, a different monotonic clock is selected that continues to advance while the system is suspended and thus can be used as the trigger to resume the system\&.
194 .sp
195 If the empty string is assigned to any of these options, the list of timers is reset (both monotonic timers and
196 \fIOnCalendar=\fR
197 timers, see below), and all prior assignments will have no effect\&.
198 .sp
199 Note that timers do not necessarily expire at the precise time configured with these settings, as they are subject to the
200 \fIAccuracySec=\fR
201 setting below\&.
202 .RE
203 .PP
204 \fIOnCalendar=\fR
205 .RS 4
206 Defines realtime (i\&.e\&. wallclock) timers with calendar event expressions\&. See
207 \fBsystemd.time\fR(7)
208 for more information on the syntax of calendar event expressions\&. Otherwise, the semantics are similar to
209 \fIOnActiveSec=\fR
210 and related settings\&.
211 .sp
212 Note that timers do not necessarily expire at the precise time configured with this setting, as it is subject to the
213 \fIAccuracySec=\fR
214 setting below\&.
215 .sp
216 May be specified more than once, in which case the timer unit will trigger whenever any of the specified expressions elapse\&. Moreover, calendar timers and monotonic timers (see above) may be combined within the same timer unit\&.
217 .sp
218 If the empty string is assigned to any of these options, the list of timers is reset (both
219 \fIOnCalendar=\fR
220 timers and monotonic timers, see above), and all prior assignments will have no effect\&.
221 .sp
222 Note that calendar timers might be triggered at unexpected times if the system\*(Aqs realtime clock is not set correctly\&. Specifically, on systems that lack a battery\-buffered Realtime Clock (RTC) it might be wise to enable
223 systemd\-time\-wait\-sync\&.service
224 to ensure the clock is adjusted to a network time source
225 \fIbefore\fR
226 the timer event is set up\&. Timer units with at least one
227 \fIOnCalendar=\fR
228 expression are automatically ordered after
229 time\-sync\&.target, which
230 systemd\-time\-wait\-sync\&.service
231 is ordered before\&.
232 .sp
233 When a system is temporarily put to sleep (i\&.e\&. system suspend or hibernation) the realtime clock does not pause\&. When a calendar timer elapses while the system is sleeping it will not be acted on immediately, but once the system is later resumed it will catch up and process all timers that triggered while the system was sleeping\&. Note that if a calendar timer elapsed more than once while the system was continuously sleeping the timer will only result in a single service activation\&. If
234 \fIWakeSystem=\fR
235 (see below) is enabled a calendar time event elapsing while the system is suspended will cause the system to wake up (under the condition the system\*(Aqs hardware supports time\-triggered wake\-up functionality)\&.
236 .sp
237 Added in version 197\&.
238 .RE
239 .PP
240 \fIAccuracySec=\fR
241 .RS 4
242 Specify the accuracy the timer shall elapse with\&. Defaults to 1min\&. The timer is scheduled to elapse within a time window starting with the time specified in
243 \fIOnCalendar=\fR,
244 \fIOnActiveSec=\fR,
245 \fIOnBootSec=\fR,
246 \fIOnStartupSec=\fR,
247 \fIOnUnitActiveSec=\fR
248 or
249 \fIOnUnitInactiveSec=\fR
250 and ending the time configured with
251 \fIAccuracySec=\fR
252 later\&. Within this time window, the expiry time will be placed at a host\-specific, randomized, but stable position that is synchronized between all local timer units\&. This is done in order to optimize power consumption to suppress unnecessary CPU wake\-ups\&. To get best accuracy, set this option to 1us\&. Note that the timer is still subject to the timer slack configured via
253 \fBsystemd-system.conf\fR(5)\*(Aqs
254 \fITimerSlackNSec=\fR
255 setting\&. See
256 \fBprctl\fR(2)
257 for details\&. To optimize power consumption, make sure to set this value as high as possible and as low as necessary\&.
258 .sp
259 Note that this setting is primarily a power saving option that allows coalescing CPU wake\-ups\&. It should not be confused with
260 \fIRandomizedDelaySec=\fR
261 (see below) which adds a random value to the time the timer shall elapse next and whose purpose is the opposite: to stretch elapsing of timer events over a longer period to reduce workload spikes\&. For further details and explanations and how both settings play together, see below\&.
262 .sp
263 Added in version 209\&.
264 .RE
265 .PP
266 \fIRandomizedDelaySec=\fR
267 .RS 4
268 Delay the timer by a randomly selected, evenly distributed amount of time between 0 and the specified time value\&. Defaults to 0, indicating that no randomized delay shall be applied\&. Each timer unit will determine this delay randomly before each iteration, unless modified with
269 \fIFixedRandomDelay=\fR, see below\&. The delay is added on top of the next determined elapsing time or the service manager\*(Aqs startup time, whichever is later\&.
270 .sp
271 This setting is useful to stretch dispatching of similarly configured timer events over a certain time interval, to prevent them from firing all at the same time, possibly resulting in resource congestion on the local system\&.
272 .sp
273 Note the relation to
274 \fIAccuracySec=\fR
275 above: the latter allows the service manager to coalesce timer events within a specified time range in order to minimize wakeups, while this setting does the opposite: it stretches timer events over an interval, to make it unlikely that they fire simultaneously\&. If
276 \fIRandomizedDelaySec=\fR
277 and
278 \fIAccuracySec=\fR
279 are used in conjunction, first the randomized delay is added, and then the result is possibly further shifted to coalesce it with other timer events happening on the system\&. As mentioned above
280 \fIAccuracySec=\fR
281 defaults to 1 minute and
282 \fIRandomizedDelaySec=\fR
283 to 0, thus encouraging coalescing of timer events\&. In order to optimally stretch timer events over a certain range of time, set
284 \fIAccuracySec=1us\fR
285 and
286 \fIRandomizedDelaySec=\fR
287 to some higher value\&.
288 .sp
289 Added in version 229\&.
290 .RE
291 .PP
292 \fIFixedRandomDelay=\fR
293 .RS 4
294 Takes a boolean argument\&. When enabled, the randomized delay specified by
295 \fIRandomizedDelaySec=\fR
296 is chosen deterministically, and remains stable between all firings of the same timer, even if the manager is restarted\&. The delay is derived from the machine ID, the manager\*(Aqs user identifier, and the timer unit\*(Aqs name\&. This effectively creates a unique fixed offset for each timer, reducing the jitter in firings of an individual timer while still avoiding firing at the same time as other similarly configured timers\&.
297 .sp
298 This setting has an effect only if
299 \fIRandomizedDelaySec=\fR
300 is not 0\&. Defaults to
301 \fBfalse\fR\&.
302 .sp
303 Added in version 247\&.
304 .RE
305 .PP
306 \fIRandomizedOffsetSec=\fR
307 .RS 4
308 Offsets the timer by a stable, randomly\-selected, and evenly distributed amount of time between 0 and the specified time value\&. Defaults to 0, indicating that no such offset shall be applied\&. The offset is chosen deterministically, and is derived the same way as
309 \fIFixedRandomDelay=\fR, see above\&. The offset is added on top of the next determined elapsing time\&. This setting only has an effect on timers configured with
310 \fIOnCalendar=\fR, and it can be combined with
311 \fIRandomizedDelaySec=\fR\&.
312 .sp
313 Much like
314 \fIRandomizedDelaySec=\fR, this setting is for distributing timer events to prevent them from firing all at once\&. However, this setting is most useful to prevent resource congestion on a remote service, from a fleet of similarly\-configured clients\&. Unlike
315 \fIRandomizedDelaySec=\fR, this setting applies its offset with no regard to manager startup time\&. This maintains the periodicity of configured
316 \fIOnCalendar=\fR
317 events across manager restarts\&.
318 .sp
319 For example, let\*(Aqs say you\*(Aqre running a backup service and have a fleet of laptops that wish to make backups weekly\&. To distribute load on the backup service, each laptop should randomly pick a weekday to upload its backups\&. This could be achieved by setting
320 \fIOnCalendar=\fR
321 to
322 "weekly", and then configuring a
323 \fIRandomizedDelaySec=\fR
324 of
325 "5 days"
326 with
327 \fIFixedRandomDelay=\fR
328 enabled\&. Let\*(Aqs say that some laptop randomly chooses a delay of 4 days\&. If this laptop is restarted more often than that, then the timer will never fire: on each fresh boot, the 4 day delay is restarted and will not be finished by the time of the next shutdown\&. Instead, you should use
329 \fIRandomizedOffsetSec=\fR, which will maintain the configured weekly cadence of timer events, even across reboots\&.
330 .sp
331 Added in version 258\&.
332 .RE
333 .PP
334 \fIDeferReactivation=\fR
335 .RS 4
336 Takes a boolean argument\&. When enabled, the timer schedules the next elapse based on the trigger unit entering inactivity, instead of the last trigger time\&. This is most apparent in the case where the service unit takes longer to run than the timer interval\&. With this setting enabled, the timer will schedule the next elapse based on when the service finishes running, and so it will have to wait until the next realtime elapse time to trigger\&. Otherwise, the default behavior is for the timer unit to immediately trigger again once the service finishes running\&. This happens because the timer schedules the next elapse based on the previous trigger time, and since the interval is shorter than the service runtime, that elapse will be in the past, causing it to immediately trigger once done\&.
337 .sp
338 This setting has an effect only if a realtime timer has been specified with
339 \fIOnCalendar=\fR\&. Defaults to
340 \fBfalse\fR\&.
341 .sp
342 Added in version 257\&.
343 .RE
344 .PP
345 \fIOnClockChange=\fR, \fIOnTimezoneChange=\fR
346 .RS 4
347 These options take boolean arguments\&. When true, the service unit will be triggered when the system clock (\fBCLOCK_REALTIME\fR) jumps relative to the monotonic clock (\fBCLOCK_MONOTONIC\fR), or when the local system timezone is modified\&. These options can be used alone or in combination with other timer expressions (see above) within the same timer unit\&. These options default to
348 \fBfalse\fR\&.
349 .sp
350 Added in version 242\&.
351 .RE
352 .PP
353 \fIUnit=\fR
354 .RS 4
355 The unit to activate when this timer elapses\&. The argument is a unit name, whose suffix is not
356 "\&.timer"\&. If not specified, this value defaults to a service that has the same name as the timer unit, except for the suffix\&. (See above\&.) It is recommended that the unit name that is activated and the unit name of the timer unit are named identically, except for the suffix\&.
357 .RE
358 .PP
359 \fIPersistent=\fR
360 .RS 4
361 Takes a boolean argument\&. If true, the time when the service unit was last triggered is stored on disk\&. When the timer is activated, the service unit is triggered immediately if it would have been triggered at least once during the time when the timer was inactive\&. Such triggering is nonetheless subject to the delay imposed by
362 \fIRandomizedDelaySec=\fR\&. This is useful to catch up on missed runs of the service when the system was powered down\&. Note that this setting only has an effect on timers configured with
363 \fIOnCalendar=\fR\&. Defaults to
364 \fBfalse\fR\&.
365 .sp
366 Use
367 \fBsystemctl clean \-\-what=state \&...\fR
368 on the timer unit to remove the timestamp file maintained by this option from disk\&. In particular, use this command before uninstalling a timer unit\&. See
369 \fBsystemctl\fR(1)
370 for details\&.
371 .sp
372 Added in version 212\&.
373 .RE
374 .PP
375 \fIWakeSystem=\fR
376 .RS 4
377 Takes a boolean argument\&. If true, an elapsing timer will cause the system to resume from suspend, should it be suspended and if the system supports this\&. Note that this option will only make sure the system resumes on the appropriate times, it will not take care of suspending it again after any work that is to be done is finished\&. Defaults to
378 \fBfalse\fR\&.
379 .sp
380 Note that this functionality requires privileges and is thus generally only available in the system service manager\&.
381 .sp
382 Note that behaviour of monotonic clock timers (as configured with
383 \fIOnActiveSec=\fR,
384 \fIOnBootSec=\fR,
385 \fIOnStartupSec=\fR,
386 \fIOnUnitActiveSec=\fR,
387 \fIOnUnitInactiveSec=\fR, see above) is altered depending on this option\&. If false, a monotonic clock is used that is paused during system suspend (\fBCLOCK_MONOTONIC\fR), if true a different monotonic clock is used that continues advancing during system suspend (\fBCLOCK_BOOTTIME\fR), see
388 \fBclock_getres\fR(2)
389 for details\&.
390 .sp
391 Added in version 212\&.
392 .RE
393 .PP
394 \fIRemainAfterElapse=\fR
395 .RS 4
396 Takes a boolean argument\&. If true, a timer will stay loaded, and its state remains queryable even after it elapsed and the associated unit (as configured with
397 \fIUnit=\fR, see above) deactivated again\&. If false, an elapsed timer unit that cannot elapse anymore is unloaded once its associated unit deactivated again\&. Turning this off is particularly useful for transient timer units\&. Note that this setting has an effect when repeatedly starting a timer unit: if
398 \fIRemainAfterElapse=\fR
399 is on, starting the timer a second time has no effect\&. However, if
400 \fIRemainAfterElapse=\fR
401 is off and the timer unit was already unloaded, it can be started again, and thus the service can be triggered multiple times\&. Defaults to
402 \fBtrue\fR\&.
403 .sp
404 Added in version 229\&.
405 .RE
406 .PP
407 Check
408 \fBsystemd.unit\fR(5),
409 \fBsystemd.exec\fR(5), and
410 \fBsystemd.kill\fR(5)
411 for more settings\&.
412 .SH "SEE ALSO"
413 .PP
414 Environment variables with details on the trigger will be set for triggered units\&. See the
415 "Environment Variables Set or Propagated by the Service Manager"
416 section in
417 \fBsystemd.exec\fR(5)
418 for more details\&.
419 .PP
420 \fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd.unit\fR(5), \fBsystemd.service\fR(5), \fBsystemd.time\fR(7), \fBsystemd.directives\fR(7), \fBsystemd-system.conf\fR(5), \fBprctl\fR(2)