I noticed that this server hasn't been terribly available since upgrade to Ubuntu 19.04: more than once I went looking for the server and it was offline.
Now that I'm finally progressing with centralized RSyslog setup at home, I noticed that the UniFi controller server was reporting the following in logs recently:
So, it appears the power management has improved enough to start bringing this server to sleep every hour or so.
Since this is a recent enough version of Ubuntu, I figured there should be a way to disable power management using systemctl. Turns out, there is.
Confirm Sleep Status with systemd
IMPORTANT: I didn't run this command on server, so this is example from another system: I'm running it on my XPS laptop with Ubuntu, just to show you expected output.
As you can see, my laptop rests well and often:
[email protected]:~ $ systemctl status sleep.target ● sleep.target - Sleep Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd.special(7) Feb 24 13:18:08 xps systemd: Reached target Sleep. Feb 26 13:29:31 xps systemd: Stopped target Sleep. Feb 26 13:29:57 xps systemd: Reached target Sleep. Feb 26 13:30:19 xps systemd: Stopped target Sleep.
Disable Sleep in Ubuntu with systemd
This is what I did on my server:
[email protected]:/ # sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target Created symlink /etc/systemd/system/sleep.target → /dev/null. Created symlink /etc/systemd/system/suspend.target → /dev/null. Created symlink /etc/systemd/system/hibernate.target → /dev/null. Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null. [email protected]:/etc/pm/sleep.d#
This is obviously a very simple way of disabling power management, but I like it because it's standard and logical enough – there's no need to edit config files or create cronjobs manually controlling sleep functionality.
The service is dead, no power management is happening and most importantly, my server has been up for 12 hours now.
[email protected]:~$ systemctl status sleep.target ● sleep.target Loaded: masked (Reason: Unit sleep.target is masked.) Active: inactive (dead)
(re) Enabling Sleep in Ubuntu with systemctl
When the time comes and I would like to re-enable power management and sleep/hibernation, this will be the command I'll run:
[email protected]:/etc/pm/sleep.d# sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
That's all for now. Have a great day!