How to automatically shutdown Ubuntu when idle?
Solution 1:
If you are using a recent version of Ubuntu Desktop, you can configure this pretty quickly using dconf-editor
. Here's how:
-
Install
dconf-editor
if it is not already present:sudo apt update sudo apt install dconf-editor
-
Open
dconf-editor
: -
Click the magnifying glass to start a search, and type "sleep-inactive":
-
Edit the
sleep-inactive-ac-timeout
value to1800
(30 Minutes): -
Edit the
sleep-inactive-ac-type
value toshutdown
(or something else you might prefer): -
Be sure to save your changes.
That's all there is to it.
Solution 2:
matigo's answer works and is pretty easy, but if you prefer the command line, you can do the same with the following commands:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 1800
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'shutdown'