User Tools

Site Tools


wiki:linux:disable_system_sleep

Disable System Sleep on Linux (SystemD)

Sometimes (a lot of times…) you have systems that you don't want to go to sleep. While you could login to each system and disable it through your desktop environment or push out a change through DConf (ugh shudders), there is a much better way to do so programmatically that is also much easier to script or codify for configuration management systems (yay for Puppet!).

Run the commands below (as root, or prefix with sudo):

systemctl mask sleep.target
systemctl mask suspend.target
systemctl mask hibernate.target
systemctl mask hybrid-sleep.target

Nice and easy. You can run that script via SSH or Ansible-ize it or however you prefer to push those changes out to systems at scale.

SystemD has its warts, but this isn't one of them.

wiki/linux/disable_system_sleep.txt · Last modified: 2025/01/07 12:37 by Greg