I have a small Ubuntu 18.04 system (should work on 16.04) that is running headless and appears to be going to sleep on me.
I found references to changing the settings for a laptop when the lid was closed, but this isn't a laptop and so I didn't believe that would be the cause of my system sleeping. If simply pressed the power button quickly, the system responded to ping/ssh, etc and I could see that the system showed it had been up for several days (since my last known reboot).
I also ran the command below and saw that it "reached target Sleep"
me@ubuntu:~$systemctl status sleep.target
● sleep.target - Sleep
Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)
Active: inactive (dead) since Sun 2022-07-10 22:47:44 UTC; 17min ago
Docs: man:systemd.special(7)
Jul 10 17:16:33 ubuntu systemd[1]: Reached target Sleep.
Jul 10 22:47:44 ubuntu systemd[1]: Stopped target Sleep.
To disable Suspend mode, I ran the following command:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
To re-enable it run:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
For good measure, I also changed the Power Mangement Settings (which can also be done in the GUI if you are running one).
Power Management Settings (without a GUI)
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout '0' && gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout '0'