On Ubuntu 16.04 LTS, I successfully used the following to disable suspend:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
And this to re-enable it:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
From man systemctl
:
mask NAME...
Mask one or more units, as specified on the command line. This
will link these unit files to /dev/null, making it impossible to
start them. This is a stronger version of disable, since it
prohibits all kinds of activation of the unit, including
enablement and manual activation. Use this option with care. This
honors the --runtime option to only mask temporarily until the
next reboot of the system. The --now option may be used to ensure
that the units are also stopped. This command expects valid unit
names only, it does not accept unit file paths.
unmask NAME...
Unmask one or more unit files, as specified on the command line.
This will undo the effect of mask. This command expects valid
unit names only, it does not accept unit file paths.
mask
orunmask
do anyways? Never heard of those before.) – ArtOfWarfare Sep 15 '17 at 00:53man systemctl
"Mask one or more units, as specified on the command line. This will link these unit files to /dev/null, making it impossible to start them. This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care. This honors the --runtime option to only mask temporarily until the next reboot of the system. The --now option may be used to ensure that the units are also stopped. This command expects valid unit names only, it does not accept unit file paths." – Centimane Oct 24 '17 at 18:17mask
ed or not? Obviously I could try just running them and see what happens, but that would potentially cause the side effect of putting my computer to sleep (which would be... bad... it has issues waking up, which is why I want to just ensure it never sleeps.) – ArtOfWarfare Oct 24 '17 at 19:33/etc/systemd/system/
for a link to/dev/null
– Centimane Oct 24 '17 at 19:38systemctl show -p FragmentPath [service]
. TheFragmentPath
property tells you wheresystemd
thinks the unit file lives. A masked service will say/dev/null
– Centimane Oct 24 '17 at 19:41systemd-logind
was trying to execute the suspend service but couldn't. The solution is to ignore the lid withHandleLidSwitch=ignore
in/etc/systemd/logind.conf
– Djizeus Jun 08 '19 at 22:17explicity lists the
– Tom Russell Mar 29 '21 at 19:46target
s (suspend, etc) asmasked
systemd-logind
spammed my/var/log/auth.log
until it filled the disk. MASKING IS NOT THE WAY TO GO! – gosuto Aug 01 '21 at 09:28