Score:1

What can actually trigger the Active status of a systemd target unit, such as suspend.target?

cn flag
s.k

I'm having a server that apparently randomly goes to sleep and I cannot figure out what actually triggers that state in the system logs.

Hence my question: what process(es) or event(s) are able to actually trigger the status of the following systemd target into an active state (e.g. putting the system into sleep) on Ubuntu 22.04?

$ systemctl status suspend.target 
○ suspend.target - Suspend
     Loaded: loaded (/lib/systemd/system/suspend.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)
Score:1
id flag

From what I can see is that the power saving triggers it. Upon reading through the man systemd.special you can see that the suspend.target pulls in the sleep.target and will be called upon when it is needed.

   suspend.target
       A special target unit for suspending the system. This pulls in
       sleep.target.
   sleep.target
       A special target unit that is pulled in by suspend.target,
       hibernate.target and hybrid-sleep.target and may be used to hook
       units into the sleep state logic.

It is part of the Special System Units that is managed by the system service manager.

Running systemctl start systemd-suspend.service will put your system right to sleep as it is now active, so it has to remain inactive until it is needed.

s.k avatar
cn flag
s.k
Hmm, so there should be something which trigger or call that `systemd.special` on my server recently, but I cannot figure out why/what. I'll study it more deeply, hopefully I will understand what happens. Because for me, these states make sense on a personal computer, but they should not be triggered on a server.
Score:1
cn flag

That would be

systemctl enable suspend.target 

Mind that enable will error out if the system service has faults and it will show this:

$ systemctl enable suspend.target 
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
 
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

If so to enable it ... that issue needs to be fixed 1st.

s.k avatar
cn flag
s.k
...which is basically the case for all suspend/sleep/hibernate targets, hence my question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.