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 pauses, too.
134
135           If the empty string is assigned to any of these options, the list
136           of timers is reset (both monotonic timers and OnCalendar= timers,
137           see below), and all prior assignments will have no effect.
138
139           Note that timers do not necessarily expire at the precise time
140           configured with these settings, as they are subject to the
141           AccuracySec= setting below.
142
143       OnCalendar=
144           Defines realtime (i.e. wallclock) timers with calendar event
145           expressions. See systemd.time(7) for more information on the syntax
146           of calendar event expressions. Otherwise, the semantics are similar
147           to OnActiveSec= and related settings.
148
149           Note that timers do not necessarily expire at the precise time
150           configured with this setting, as it is subject to the AccuracySec=
151           setting below.
152
153           May be specified more than once, in which case the timer unit will
154           trigger whenever any of the specified expressions elapse. Moreover
155           calendar timers and monotonic timers (see above) may be combined
156           within the same timer unit.
157
158           If the empty string is assigned to any of these options, the list
159           of timers is reset (both OnCalendar= timers and monotonic timers,
160           see above), and all prior assignments will have no effect.
161
162       AccuracySec=
163           Specify the accuracy the timer shall elapse with. Defaults to 1min.
164           The timer is scheduled to elapse within a time window starting with
165           the time specified in OnCalendar=, OnActiveSec=, OnBootSec=,
166           OnStartupSec=, OnUnitActiveSec= or OnUnitInactiveSec= and ending
167           the time configured with AccuracySec= later. Within this time
168           window, the expiry time will be placed at a host-specific,
169           randomized, but stable position that is synchronized between all
170           local timer units. This is done in order to optimize power
171           consumption to suppress unnecessary CPU wake-ups. To get best
172           accuracy, set this option to 1us. Note that the timer is still
173           subject to the timer slack configured via systemd-system.conf(5)'s
174           TimerSlackNSec= setting. See prctl(2) for details. To optimize
175           power consumption, make sure to set this value as high as possible
176           and as low as necessary.
177
178       RandomizedDelaySec=
179           Delay the timer by a randomly selected, evenly distributed amount
180           of time between 0 and the specified time value. Defaults to 0,
181           indicating that no randomized delay shall be applied. Each timer
182           unit will determine this delay randomly before each iteration, and
183           the delay will simply be added on top of the next determined
184           elapsing time. This is useful to stretch dispatching of similarly
185           configured timer events over a certain amount time, to avoid that
186           they all fire at the same time, possibly resulting in resource
187           congestion. Note the relation to AccuracySec= above: the latter
188           allows the service manager to coalesce timer events within a
189           specified time range in order to minimize wakeups, the former does
190           the opposite: it stretches timer events over a time range, to make
191           it unlikely that they fire simultaneously. If RandomizedDelaySec=
192           and AccuracySec= are used in conjunction, first the randomized
193           delay is added, and then the result is possibly further shifted to
194           coalesce it with other timer events happening on the system. As
195           mentioned above AccuracySec= defaults to 1min and
196           RandomizedDelaySec= to 0, thus encouraging coalescing of timer
197           events. In order to optimally stretch timer events over a certain
198           range of time, make sure to set RandomizedDelaySec= to a higher
199           value, and AccuracySec=1us.
200
201       OnClockChange=, OnTimezoneChange=
202           These options take boolean arguments. When true, the service unit
203           will be triggered when the system clock (CLOCK_REALTIME) jumps
204           relative to the monotonic clock (CLOCK_MONOTONIC), or when the
205           local system timezone is modified. These options can be used alone
206           or in combination with other timer expressions (see above) within
207           the same timer unit. These options default to false.
208
209       Unit=
210           The unit to activate when this timer elapses. The argument is a
211           unit name, whose suffix is not ".timer". If not specified, this
212           value defaults to a service that has the same name as the timer
213           unit, except for the suffix. (See above.) It is recommended that
214           the unit name that is activated and the unit name of the timer unit
215           are named identically, except for the suffix.
216
217       Persistent=
218           Takes a boolean argument. If true, the time when the service unit
219           was last triggered is stored on disk. When the timer is activated,
220           the service unit is triggered immediately if it would have been
221           triggered at least once during the time when the timer was
222           inactive. This is useful to catch up on missed runs of the service
223           when the system was powered down. Note that this setting only has
224           an effect on timers configured with OnCalendar=. Defaults to false.
225
226           Use systemctl clean --what=state ...  on the timer unit to remove
227           the timestamp file maintained by this option from disk. In
228           particular, use this command before uninstalling a timer unit. See
229           systemctl(1) for details.
230
231       WakeSystem=
232           Takes a boolean argument. If true, an elapsing timer will cause the
233           system to resume from suspend, should it be suspended and if the
234           system supports this. Note that this option will only make sure the
235           system resumes on the appropriate times, it will not take care of
236           suspending it again after any work that is to be done is finished.
237           Defaults to false.
238
239           Note that this functionality requires privileges and is thus
240           generally only available in the system service manager.
241
242       RemainAfterElapse=
243           Takes a boolean argument. If true, an elapsed timer will stay
244           loaded, and its state remains queryable. If false, an elapsed timer
245           unit that cannot elapse anymore is unloaded. Turning this off is
246           particularly useful for transient timer units that shall disappear
247           after they first elapse. Note that this setting has an effect on
248           repeatedly starting a timer unit that only elapses once: if
249           RemainAfterElapse= is on, it will not be started again, and is
250           guaranteed to elapse only once. However, if RemainAfterElapse= is
251           off, it might be started again if it is already elapsed, and thus
252           be triggered multiple times. Defaults to yes.
253

SEE ALSO

255       systemd(1), systemctl(1), systemd.unit(5), systemd.service(5),
256       systemd.time(7), systemd.directives(7), systemd-system.conf(5),
257       prctl(2)
258
259
260
261systemd 243                                                   SYSTEMD.TIMER(5)
Impressum