SYSTEMD-SUSPEND.SERVICE(8)

๐Ÿ’ค systemd-suspend.service(8) โ€” the group chat where your laptop goes night-night

okay bestie, welcome to the systemd-suspend.service manual page (that's the manual name, we're folding it in right here at the top like a lil name tag ๐ŸŽ€). this is the whole sleep-state saga: systemd-suspend.service, systemd-hibernate.service, systemd-hybrid-sleep.service, systemd-suspend-then-hibernate.service, and systemd-sleep. System sleep state logic, periodt. โœจ


โœจ NAME โœจ

systemd-suspend.service, systemd-hibernate.service, systemd-hybrid-sleep.service, systemd-suspend-then-hibernate.service, systemd-sleep โ€” System sleep state logic ๐Ÿ’ค


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

systemd-suspend.service
systemd-hibernate.service
systemd-hybrid-sleep.service
systemd-suspend-then-hibernate.service
/usr/lib/systemd/system-sleep

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so. systemd-suspend.service is a system service that gets pulled in by suspend.target, and it's the one responsible for the actual system suspend. like, the real one. no middleman. ๐Ÿ‘‘

same energy for systemd-hibernate.service โ€” it's pulled in by hibernate.target to execute the actual hibernation. and then systemd-hybrid-sleep.service is pulled in by hybrid-sleep.target to execute hybrid hibernation with system suspend, and it's also pulled in by suspend-then-hibernate.target to execute system suspend with a timeout that will activate hibernate later. multitasking icon fr fr. ๐Ÿฆ‹


immediately before entering system suspend and/or hibernation, systemd-suspend.service (and the other mentioned units, respectively) will run all executables in /usr/lib/systemd/system-sleep/ and pass two arguments to them. first argument? "pre". second argument? either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate" depending on the chosen action. โœจ

an environment variable called "SYSTEMD_SLEEP_ACTION" will be set and it'll contain the sleep action that is processing. this is primarily helpful for "suspend-then-hibernate", where the value of the variable will be "suspend", "hibernate", or "suspend-after-failed-hibernate" in cases where hibernation has failed. ๐Ÿ˜ญ we've all been there.

immediately after leaving system suspend and/or hibernation, the same executables are run again, but the first argument is now "post". all executables in this directory are executed in parallel, and execution of the action is not continued until all executables have finished. no cutting the line, besties. โณ

โš ๏ธ note that user.slice will be frozen while the executables are running, so they should not attempt to communicate with any user services expecting a reply. it's giving "left on read" ๐Ÿ’€

๐Ÿšจ note that scripts or binaries dropped in /usr/lib/systemd/system-sleep/ are intended for local use only and should be considered hacks. if applications want to react to system suspend/hibernation and resume, they should rather use the Inhibitor Locks[1]. do it the proper way, queen. ๐Ÿ’…

๐Ÿ›‘ note that systemd-suspend.service, systemd-hibernate.service, systemd-hybrid-sleep.service, and systemd-suspend-then-hibernate.service should never be executed directly. like, ever. instead, trigger system sleep with a command such as systemctl suspend or systemctl hibernate. main character energy only through the front door, okay? ๐Ÿšชโœจ

internally, this service will echo a string like "mem" into /sys/power/state, to trigger the actual system suspend. what exactly is written where can be configured in the [Sleep] section of /etc/systemd/sleep.conf or a sleep.conf.d file. see systemd-sleep.conf(5). ๐Ÿ“

๐Ÿ’ก note that by default these services freeze user.slice while they run. this prevents the execution of any process in any of the user sessions while the system is entering into and resuming from sleep. thus, this prevents the hooks in /usr/lib/systemd/system-sleep/, or any other process for that matter, from communicating with any user session process during sleep. frozen. like your ex's heart. ๐ŸงŠ

๐ŸŽ€ OPTIONS ๐ŸŽ€

systemd-sleep understands the following commands:

  • -h, --help โ€” print a short help text and exit. short king behavior. ๐Ÿ‘‘
  • --version โ€” print a short version string and exit. just the tea, no extras. โ˜•
  • suspend, hibernate, suspend-then-hibernate, hybrid-sleep โ€” suspend, hibernate, suspend then hibernate, or put the system to hybrid sleep. pick your poison, bestie, all four are iconic. ๐Ÿ’œ

Added in version 203.


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

systemd-sleep.conf(5), systemd(1), systemctl(1), systemd.special(7), systemd-halt.service(8)


๐Ÿ“ NOTES ๐Ÿ“

  1. Inhibitor Locks https://systemd.io/INHIBITOR_LOCKS

and that's the whole page, bestie!! ๐Ÿซถ this was systemd 262.1 talking, and you're reading SYSTEMD-SUSPEND.SERVICE(8) โ€” go forth, suspend responsibly, and never run those units directly. mwah ๐Ÿ’‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from
  • arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms