Ubuntu Server "shuts down" ~daily
I have a pair of P340Tiny systems acting as web servers for a couple of non-profits in the community and have not run into this particular issue. At first I thought that you might be running the device headless, as doing so may trigger the BIOS on some systems to force a shut down after a certain amount of time with no display. The same sort of “feature” exists on some Lenovo All-in-One’s, shutting the machine off if there has been zero activity from keyboards or mice for 16 hours. However, looking through the user guide at the power features, I do not see any such functionality. I also looked at the Power tab in the BIOS of one of my P340Tinies and didn’t see anything suggesting the machine might shut down on its own either:
One thing I can say is that the P340Tiny units I’m running do not exhibit the behaviour you see. They both run Ubuntu Server 20.04.1 and are configured to run until they’re told otherwise. Aside from the very occasional reboot, they’ve been running 24/7.
That said, you had mentioned that you installed the ubuntu-desktop
package on your machine for a GUI, and this has me thinking there is something in systemd
that is shutting your machine off.
Check for a Sleep.Target
On desktop systems there is a systemd-sleep
service that is used for various power-saving modes. This service may still exist on your server despite having Gnome Desktop removed. You can check for it’s existence with this command:
sudo systemctl status sleep.target
If the service exists and is running, you’ll see a response that looks something like this:
● sleep.target - Sleep
Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
If you see an output like this, then you’ll need to disable the power-saving bits of systemd
. Fortunately, it’s not too difficult:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
This will disable sleep, suspend, hibernate, and the “hybrid-sleep” features in one step. You should see something like this as the output:
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
With these things disabled, now you can check for completeness:
$ systemctl status sleep.target
● sleep.target
Loaded: masked (Reason: Unit sleep.target is masked.)
Active: inactive (dead)
Note that the Loaded
line now reads masked
. Any attempt by systemd
to sleep will be ignored.
This change takes effect immediately, so there is no need to reload a daemon or reboot the machine. Hopefully it will give you what you need.