Debian Codegraph @

man/systemd-suspend.service.xml

raw
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-suspend.service"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>systemd-suspend.service</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd-suspend.service</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd-suspend.service</refname>
21 <refname>systemd-hibernate.service</refname>
22 <refname>systemd-hybrid-sleep.service</refname>
23 <refname>systemd-suspend-then-hibernate.service</refname>
24 <refname>systemd-sleep</refname>
25 <refpurpose>System sleep state logic</refpurpose>
26 </refnamediv>
27
28 <refsynopsisdiv>
29 <para><simplelist>
30 <member><filename>systemd-suspend.service</filename></member>
31 <member><filename>systemd-hibernate.service</filename></member>
32 <member><filename>systemd-hybrid-sleep.service</filename></member>
33 <member><filename>systemd-suspend-then-hibernate.service</filename></member>
34 <member><filename>/usr/lib/systemd/system-sleep</filename></member>
35 </simplelist></para>
36 </refsynopsisdiv>
37
38 <refsect1>
39 <title>Description</title>
40
41 <para><filename>systemd-suspend.service</filename> is a system
42 service that is pulled in by <filename>suspend.target</filename>
43 and is responsible for the actual system suspend. Similarly,
44 <filename>systemd-hibernate.service</filename> is pulled in by
45 <filename>hibernate.target</filename> to execute the actual
46 hibernation. Finally,
47 <filename>systemd-hybrid-sleep.service</filename> is pulled in by
48 <filename>hybrid-sleep.target</filename> to execute hybrid
49 hibernation with system suspend and pulled in by
50 <filename>suspend-then-hibernate.target</filename> to execute system suspend
51 with a timeout that will activate hibernate later.</para>
52
53 <para>Immediately before entering system suspend and/or
54 hibernation <filename>systemd-suspend.service</filename> (and the
55 other mentioned units, respectively) will run all executables in
56 <filename>/usr/lib/systemd/system-sleep/</filename> and pass two
57 arguments to them. The first argument will be
58 <literal>pre</literal>, the second either
59 <literal>suspend</literal>, <literal>hibernate</literal>,
60 <literal>hybrid-sleep</literal>, or <literal>suspend-then-hibernate</literal>
61 depending on the chosen action. An environment variable called <literal>SYSTEMD_SLEEP_ACTION</literal>
62 will be set and contain the sleep action that is processing. This is primarily helpful for
63 <literal>suspend-then-hibernate</literal> where the value of the variable will be <literal>suspend</literal>, <literal>hibernate</literal>,
64 or <literal>suspend-after-failed-hibernate</literal> in cases where hibernation has failed.
65 Immediately after leaving system suspend and/or hibernation the
66 same executables are run, but the first argument is now
67 <literal>post</literal>. All executables in this directory are
68 executed in parallel, and execution of the action is not continued
69 until all executables have finished. Note that <filename>user.slice</filename> will
70 be frozen while the executables are running, so they should not attempt to
71 communicate with any user services expecting a reply.</para>
72
73 <para>Note that scripts or binaries dropped in
74 <filename>/usr/lib/systemd/system-sleep/</filename> are intended
75 for local use only and should be considered hacks. If applications
76 want to react to system suspend/hibernation and resume, they should rather use the
77 <ulink url="https://systemd.io/INHIBITOR_LOCKS">Inhibitor Locks</ulink>.</para>
78
79 <para>Note that <filename>systemd-suspend.service</filename>,
80 <filename>systemd-hibernate.service</filename>, <filename>systemd-hybrid-sleep.service</filename>, and
81 <filename>systemd-suspend-then-hibernate.service</filename> should never be executed directly. Instead,
82 trigger system sleep with a command such as <command>systemctl suspend</command> or <command>systemctl
83 hibernate</command>.</para>
84
85 <para>Internally, this service will echo a string like
86 <literal>mem</literal> into <filename>/sys/power/state</filename>,
87 to trigger the actual system suspend. What exactly is written
88 where can be configured in the [Sleep] section
89 of <filename>/etc/systemd/sleep.conf</filename> or a
90 <filename>sleep.conf.d</filename> file. See
91 <citerefentry><refentrytitle>systemd-sleep.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
92 </para>
93
94 <para>Note that by default these services freeze <filename>user.slice</filename> while they run. This prevents
95 the execution of any process in any of the user sessions while the system is entering into and resuming from
96 sleep. Thus, this prevents the hooks in <filename>/usr/lib/systemd/system-sleep/</filename>, or any other process
97 for that matter, from communicating with any user session process during sleep.</para>
98 </refsect1>
99
100 <refsect1>
101 <title>Options</title>
102
103 <para><command>systemd-sleep</command> understands the
104 following commands:</para>
105
106 <variablelist>
107 <xi:include href="standard-options.xml" xpointer="help" />
108 <xi:include href="standard-options.xml" xpointer="version" />
109
110 <varlistentry>
111 <term><option>suspend</option></term>
112 <term><option>hibernate</option></term>
113 <term><option>suspend-then-hibernate</option></term>
114 <term><option>hybrid-sleep</option></term>
115
116 <listitem><para>Suspend, hibernate, suspend then hibernate, or put the
117 system to hybrid sleep.</para>
118
119 <xi:include href="version-info.xml" xpointer="v203"/>
120 </listitem>
121 </varlistentry>
122 </variablelist>
123 </refsect1>
124
125 <refsect1>
126 <title>See Also</title>
127 <para><simplelist type="inline">
128 <member><citerefentry><refentrytitle>systemd-sleep.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
129 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
130 <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
131 <member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
132 <member><citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
133 </simplelist></para>
134 </refsect1>
135
136 </refentry>