{"id":33930,"date":"2021-06-10T14:45:05","date_gmt":"2021-06-10T14:45:05","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=33930"},"modified":"2024-04-28T14:29:14","modified_gmt":"2024-04-28T14:29:14","slug":"automatic-shutdown-hibernate-on-idle-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2021\/06\/automatic-shutdown-hibernate-on-idle-ubuntu\/","title":{"rendered":"Enable Automatic Shutdown \/ Hibernate when idle on Ubuntu"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-33105\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/gnome-icon250.png\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/gnome-icon250.png 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/gnome-icon250-150x150.png 150w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p>Unlike <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2020\/05\/lid-close-behavior-ubuntu-20-04\/\" target=\"_blank\" rel=\"noopener\">laptop lid close action<\/a>, it&#8217;s easy to tell Ubuntu to shutdown or hibernate automatically when reached idle timeout.<\/p>\n<p>In all current Ubuntu releases, including <b>Ubuntu 18.04<\/b>, <b>Ubuntu 20.04<\/b>, <b>Ubuntu 22.04<\/b>, and <b>Ubuntu 24.04<\/b> running with the default GNOME desktop, you can enable &#8216;<i><b>Automatic Suspend<\/b><\/i>&#8216; feature in Power Settings easily.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-33932\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings-600x400.jpg\" alt=\"\" width=\"600\" height=\"400\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings-600x400.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings-300x200.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings-768x512.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-suspend-settings.jpg 1021w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>What if you want to power off, hibernate, or even log-out Ubuntu after it reached inactivity timeout? Here&#8217;s how to do this in two ways.<\/p>\n<h3>Method 1. Run 2 commands to enable Automatic Shutdown \/ Hibernate:<\/h3>\n<p>Firstly open terminal either from system application launcher or by pressing Ctrl+Alt+T on keyboard.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/04\/terminal-focal.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9967\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/04\/terminal-focal.jpg\" alt=\"\" width=\"490\" height=\"256\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/04\/terminal-focal.jpg 490w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/04\/terminal-focal-450x235.jpg 450w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/a><\/p>\n<p><b>NOTE: Hibernate does not function out-of-the-box in current Ubuntu releases. You have to <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2021\/08\/enable-hibernate-ubuntu-21-10\/\" target=\"_blank\" rel=\"noopener\">enable it first if you need automatic hibernation<\/a>.<\/b><\/p>\n<p>When terminal opens, run command <b>for computer on AC power<\/b>:<\/p>\n<ul>\n<li>Enable automatic shutdown for desktop PC or laptop on AC power:\n<pre style=\"border: none;\">gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'shutdown'<\/pre>\n<p>For choices, you can change &#8216;shutdown&#8217; in command to &#8216;<i>hibernate<\/i>&#8216;, &#8216;<i>logout<\/i>&#8216;, &#8216;<i>nothing<\/i>&#8216;, etc.<\/li>\n<li>Change the inactivity timeout (in seconds), half an hour for instance:\n<pre style=\"border: none;\">gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 1800<\/pre>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-33933\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle-600x222.jpg\" alt=\"\" width=\"600\" height=\"222\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle-600x222.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle-300x111.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle-768x284.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-idle.jpg 776w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>For laptops on battery<\/strong>, use following commands instead:<\/p>\n<pre style=\"border: none;\">gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'shutdown'<\/pre>\n<pre style=\"border: none;\">gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 1800<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-33934\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery-600x219.jpg\" alt=\"\" width=\"600\" height=\"219\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery-600x219.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery-300x110.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery-768x281.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/automatic-shutdown-battery.jpg 794w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Method 2: Change system idle action via Dconf Editor.<\/h3>\n<p>For those prefer graphical configuration tool, search for and install &#8216;<b>Dconf Editor<\/b>&#8216; from Ubuntu Software.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-33935\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-600x346.jpg\" alt=\"\" width=\"600\" height=\"346\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-600x346.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-300x173.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-768x442.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal.jpg 887w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Then launch the tool, and go to &#8216;<i>org\/gnome\/settings-daemon\/plugins\/power<\/i>&#8216;.<\/p>\n<p>Next scroll down, find out and change the values of &#8216;<i>sleep-inactive-ac-type<\/i>&#8216; and &#8216;<i>sleep-inactive-ac-timeout<\/i>&#8216; for system idle action when on AC power.<\/p>\n<p>When on battery, change the values of &#8216;<i>sleep-inactive-battery-type<\/i>&#8216; and &#8216;<i>sleep-inactive-battery-timeout<\/i>&#8216; instead.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-33936\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action-600x342.jpg\" alt=\"\" width=\"600\" height=\"342\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action-600x342.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action-300x171.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action-768x437.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-idle-action.jpg 906w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Changes will take place immediately when you click on &#8216;Apply&#8217; button.<\/p>","protected":false},"excerpt":{"rendered":"<p>Unlike laptop lid close action, it&#8217;s easy to tell Ubuntu to shutdown or hibernate automatically when reached idle timeout. In all current Ubuntu releases, including Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04 running with the default GNOME desktop, you can enable &#8216;Automatic Suspend&#8216; feature in Power Settings easily. What if you want to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":33931,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[2036],"class_list":["post-33930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gnome-shell","tag-idle-active"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=33930"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33930\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/33931"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=33930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=33930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=33930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}