]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.timer.xml
remount-fs: split code for tracking PIDs in hashmap
[thirdparty/systemd.git] / man / systemd.timer.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
11fcc3ab 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
11fcc3ab
LP
4
5<!--
572eb058 6 SPDX-License-Identifier: LGPL-2.1+
11fcc3ab
LP
7-->
8
9<refentry id="systemd.timer">
798d3a52
ZJS
10 <refentryinfo>
11 <title>systemd.timer</title>
12 <productname>systemd</productname>
798d3a52
ZJS
13 </refentryinfo>
14
15 <refmeta>
16 <refentrytitle>systemd.timer</refentrytitle>
17 <manvolnum>5</manvolnum>
18 </refmeta>
19
20 <refnamediv>
21 <refname>systemd.timer</refname>
22 <refpurpose>Timer unit configuration</refpurpose>
23 </refnamediv>
24
25 <refsynopsisdiv>
26 <para><filename><replaceable>timer</replaceable>.timer</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para>A unit configuration file whose name ends in
33 <literal>.timer</literal> encodes information about a timer
34 controlled and supervised by systemd, for timer-based
35 activation.</para>
36
37 <para>This man page lists the configuration options specific to
38 this unit type. See
39 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
40 for the common options of all unit configuration files. The common
41 configuration items are configured in the generic [Unit] and
42 [Install] sections. The timer specific configuration options are
43 configured in the [Timer] section.</para>
44
45 <para>For each timer file, a matching unit file must exist,
46 describing the unit to activate when the timer elapses. By
47 default, a service by the same name as the timer (except for the
48 suffix) is activated. Example: a timer file
49 <filename>foo.timer</filename> activates a matching service
50 <filename>foo.service</filename>. The unit to activate may be
51 controlled by <varname>Unit=</varname> (see below).</para>
14e2baa3
LP
52
53 <para>Note that in case the unit to activate is already active at the time the timer elapses it is not restarted,
54 but simply left running. There is no concept of spawning new service instances in this case. Due to this, services
595bfe7d 55 with <varname>RemainAfterExit=</varname> set (which stay around continuously even after the service's main process
14e2baa3
LP
56 exited) are usually not suitable for activation via repetitive timers, as they will only be activated once, and
57 then stay around forever.</para>
c129bd5d
LP
58 </refsect1>
59
45f09f93 60 <refsect1>
aed5cb03 61 <title>Automatic Dependencies</title>
45f09f93 62
aed5cb03
ZJS
63 <refsect2>
64 <title>Implicit Dependencies</title>
45f09f93 65
0ccc48b5
ML
66 <para>The following dependencies are implicitly added:</para>
67
68 <itemizedlist>
69 <listitem><para>Timer units automatically gain a <varname>Before=</varname>
70 dependency on the service they are supposed to activate.</para></listitem>
71 </itemizedlist>
aed5cb03
ZJS
72 </refsect2>
73
74 <refsect2>
75 <title>Default Dependencies</title>
76
77 <para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para>
78
79 <itemizedlist>
80 <listitem><para>Timer units will automatically have dependencies of type <varname>Requires=</varname> and
81 <varname>After=</varname> on <filename>sysinit.target</filename>, a dependency of type <varname>Before=</varname>
82 on <filename>timers.target</filename>, as well as <varname>Conflicts=</varname> and <varname>Before=</varname> on
83 <filename>shutdown.target</filename> to ensure that they are stopped cleanly prior to system shutdown. Only timer
84 units involved with early boot or late system shutdown should disable the
85 <varname>DefaultDependencies=</varname> option.</para></listitem>
86
87 <listitem><para>Timer units
88 with at least one <varname>OnCalendar=</varname> directive will have an additional <varname>After=</varname>
89 dependency on <filename>time-sync.target</filename> to avoid being started before the system clock has been
90 correctly set.</para></listitem>
91 </itemizedlist>
92 </refsect2>
798d3a52
ZJS
93 </refsect1>
94
95 <refsect1>
96 <title>Options</title>
97
98 <para>Timer files must include a [Timer] section, which carries
99 information about the timer it defines. The options specific to
100 the [Timer] section of timer units are the following:</para>
101
102 <variablelist class='unit-directives'>
103 <varlistentry>
104 <term><varname>OnActiveSec=</varname></term>
105 <term><varname>OnBootSec=</varname></term>
106 <term><varname>OnStartupSec=</varname></term>
107 <term><varname>OnUnitActiveSec=</varname></term>
108 <term><varname>OnUnitInactiveSec=</varname></term>
109
110 <listitem><para>Defines monotonic timers relative to different
111 starting points: <varname>OnActiveSec=</varname> defines a
112 timer relative to the moment the timer itself is activated.
113 <varname>OnBootSec=</varname> defines a timer relative to when
114 the machine was booted up. <varname>OnStartupSec=</varname>
115 defines a timer relative to when systemd was first started.
116 <varname>OnUnitActiveSec=</varname> defines a timer relative
117 to when the unit the timer is activating was last activated.
118 <varname>OnUnitInactiveSec=</varname> defines a timer relative
119 to when the unit the timer is activating was last
120 deactivated.</para>
121
122 <para>Multiple directives may be combined of the same and of
123 different types. For example, by combining
124 <varname>OnBootSec=</varname> and
125 <varname>OnUnitActiveSec=</varname>, it is possible to define
126 a timer that elapses in regular intervals and activates a
127 specific service each time.</para>
128
129 <para>The arguments to the directives are time spans
130 configured in seconds. Example: "OnBootSec=50" means 50s after
131 boot-up. The argument may also include time units. Example:
132 "OnBootSec=5h 30min" means 5 hours and 30 minutes after
133 boot-up. For details about the syntax of time spans, see
9905e698 134 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
798d3a52
ZJS
135
136 <para>If a timer configured with <varname>OnBootSec=</varname>
137 or <varname>OnStartupSec=</varname> is already in the past
138 when the timer unit is activated, it will immediately elapse
139 and the configured unit is started. This is not the case for
140 timers defined in the other directives.</para>
141
142 <para>These are monotonic timers, independent of wall-clock
143 time and timezones. If the computer is temporarily suspended,
144 the monotonic clock stops too.</para>
145
146 <para>If the empty string is assigned to any of these options,
147 the list of timers is reset, and all prior assignments will
148 have no effect.</para>
149
150 <para>Note that timers do not necessarily expire at the
151 precise time configured with these settings, as they are
152 subject to the <varname>AccuracySec=</varname> setting
153 below.</para></listitem>
154
155 </varlistentry>
156
157 <varlistentry>
158 <term><varname>OnCalendar=</varname></term>
159
160 <listitem><para>Defines realtime (i.e. wallclock) timers with
161 calendar event expressions. See
162 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
163 for more information on the syntax of calendar event
164 expressions. Otherwise, the semantics are similar to
165 <varname>OnActiveSec=</varname> and related settings.</para>
166
167 <para>Note that timers do not necessarily expire at the
168 precise time configured with this setting, as it is subject to
169 the <varname>AccuracySec=</varname> setting
192fa38b
MS
170 below.</para>
171
172 <para>May be specified more than once.</para></listitem>
798d3a52
ZJS
173 </varlistentry>
174
175 <varlistentry>
176 <term><varname>AccuracySec=</varname></term>
177
178 <listitem><para>Specify the accuracy the timer shall elapse
179 with. Defaults to 1min. The timer is scheduled to elapse
180 within a time window starting with the time specified in
181 <varname>OnCalendar=</varname>,
182 <varname>OnActiveSec=</varname>,
183 <varname>OnBootSec=</varname>,
184 <varname>OnStartupSec=</varname>,
185 <varname>OnUnitActiveSec=</varname> or
186 <varname>OnUnitInactiveSec=</varname> and ending the time
187 configured with <varname>AccuracySec=</varname> later. Within
188 this time window, the expiry time will be placed at a
744c7693 189 host-specific, randomized, but stable position that is
798d3a52 190 synchronized between all local timer units. This is done in
744c7693
LP
191 order to optimize power consumption to suppress unnecessary
192 CPU wake-ups. To get best accuracy, set this option to
193 1us. Note that the timer is still subject to the timer slack
194 configured via
798d3a52
ZJS
195 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>'s
196 <varname>TimerSlackNSec=</varname> setting. See
197 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
198 for details. To optimize power consumption, make sure to set
199 this value as high as possible and as low as
200 necessary.</para></listitem>
201 </varlistentry>
744c7693
LP
202
203 <varlistentry>
6f5d7998 204 <term><varname>RandomizedDelaySec=</varname></term>
744c7693
LP
205
206 <listitem><para>Delay the timer by a randomly selected, evenly
207 distributed amount of time between 0 and the specified time
208 value. Defaults to 0, indicating that no randomized delay
209 shall be applied. Each timer unit will determine this delay
3118a4cf 210 randomly before each iteration, and the delay will simply be
744c7693
LP
211 added on top of the next determined elapsing time. This is
212 useful to stretch dispatching of similarly configured timer
213 events over a certain amount time, to avoid that they all fire
214 at the same time, possibly resulting in resource
215 congestion. Note the relation to
216 <varname>AccuracySec=</varname> above: the latter allows the
217 service manager to coalesce timer events within a specified
218 time range in order to minimize wakeups, the former does the
219 opposite: it stretches timer events over a time range, to make
220 it unlikely that they fire simultaneously. If
6f5d7998 221 <varname>RandomizedDelaySec=</varname> and
744c7693 222 <varname>AccuracySec=</varname> are used in conjunction, first
20cc0ac7
ZJS
223 the randomized delay is added, and then the result is
224 possibly further shifted to coalesce it with other timer
225 events happening on the system. As mentioned above
744c7693 226 <varname>AccuracySec=</varname> defaults to 1min and
6f5d7998 227 <varname>RandomizedDelaySec=</varname> to 0, thus encouraging
744c7693
LP
228 coalescing of timer events. In order to optimally stretch
229 timer events over a certain range of time, make sure to set
6f5d7998 230 <varname>RandomizedDelaySec=</varname> to a higher value, and
744c7693
LP
231 <varname>AccuracySec=1us</varname>.</para></listitem>
232 </varlistentry>
233
798d3a52
ZJS
234 <varlistentry>
235 <term><varname>Unit=</varname></term>
236
237 <listitem><para>The unit to activate when this timer elapses.
238 The argument is a unit name, whose suffix is not
239 <literal>.timer</literal>. If not specified, this value
240 defaults to a service that has the same name as the timer
241 unit, except for the suffix. (See above.) It is recommended
242 that the unit name that is activated and the unit name of the
243 timer unit are named identically, except for the
244 suffix.</para></listitem>
245 </varlistentry>
246
798d3a52
ZJS
247 <varlistentry>
248 <term><varname>Persistent=</varname></term>
249
250 <listitem><para>Takes a boolean argument. If true, the time
251 when the service unit was last triggered is stored on disk.
252 When the timer is activated, the service unit is triggered
253 immediately if it would have been triggered at least once
254 during the time when the timer was inactive. This is useful to
255 catch up on missed runs of the service when the machine was
256 off. Note that this setting only has an effect on timers
07bd0e02
EV
257 configured with <varname>OnCalendar=</varname>. Defaults
258 to <varname>false</varname>.
798d3a52
ZJS
259 </para></listitem>
260 </varlistentry>
261
262 <varlistentry>
263 <term><varname>WakeSystem=</varname></term>
264
265 <listitem><para>Takes a boolean argument. If true, an elapsing
266 timer will cause the system to resume from suspend, should it
267 be suspended and if the system supports this. Note that this
268 option will only make sure the system resumes on the
269 appropriate times, it will not take care of suspending it
270 again after any work that is to be done is finished. Defaults
271 to <varname>false</varname>.</para></listitem>
3e0c30ac
LP
272 </varlistentry>
273
274 <varlistentry>
70b4f819 275 <term><varname>RemainAfterElapse=</varname></term>
3e0c30ac
LP
276
277 <listitem><para>Takes a boolean argument. If true, an elapsed
70b4f819
LP
278 timer will stay loaded, and its state remains queriable. If
279 false, an elapsed timer unit that cannot elapse anymore is
280 unloaded. Turning this off is particularly useful for
281 transient timer units that shall disappear after they first
282 elapse. Note that this setting has an effect on repeatedly
7f3fdb7f 283 starting a timer unit that only elapses once: if
70b4f819
LP
284 <varname>RemainAfterElapse=</varname> is on, it will not be
285 started again, and is guaranteed to elapse only once. However,
23743744 286 if <varname>RemainAfterElapse=</varname> is off, it might be
70b4f819
LP
287 started again if it is already elapsed, and thus be triggered
288 multiple times. Defaults to
3e0c30ac 289 <varname>yes</varname>.</para></listitem>
798d3a52
ZJS
290 </varlistentry>
291 </variablelist>
292 </refsect1>
293
294 <refsect1>
295 <title>See Also</title>
296 <para>
297 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
298 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
299 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
300 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
301 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
302 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
303 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
304 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
305 </para>
306 </refsect1>
11fcc3ab
LP
307
308</refentry>