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