I connect to a Fedora 21 workstation with SSH, but after several minutes not using the connection the system go to sleep and I loose my connection.
So how can I disallow completely the system to go into suspend/sleep mode ?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
sudo systemctl mask suspend.target sudo systemctl mask sleep.target
Systemd manages all of this. There's a million ways for something to trigger a shutdown, including gnome/kde,
NetworkManager and of course systemd itself. The sleep and suspend targets, just like shutdown are "static" i.e. core built-in units that can not be disabled. You can however mask them and prevent
systemd from ever entering them.
--what=idle from the command - apparently this is not enough. The default is
--what=shutdown:sleep:idle, which works better (but
--what=sleep:idle should work too).
Old question, but another variant of the systemd-inhibit solution is to put the following in
~/.profile (in my case, just before byobu is launched). Then, sleep will be inhibited as long as there are login shells open (i.e. mostly SSH sessions unless you also log in from the non-GUI console).
# Inhibit idle sleep. This background process waits for the current shell to exit. nohup systemd-inhibit --who=Bash --why="Byobu running" tail --pid=$$ -f /dev/null &
I found out about the
tail --pid part here: https://stackoverflow.com/a/41613532/827828