Hey guys how could I autoshutdown Ubuntu when it is idle for more than 30 minutes?

Autosuspend leaves the PC really slow at times.

  • 1
    Is this Ubuntu Server or Ubuntu Desktop? Which version are you targeting? Some methods work with specific versions ...
    – matigo
    May 31 at 13:04
  • It is regarding desktop version. Jun 1 at 7:40
  • This is not directly related, but switching over to a SATA SSD plus adding 4GB RAM to the original 4GB gave me tremendous improvement in suspend-resume operations (almost instantaneous from up to a minute) as well as cold boot-up time (less than 5 seconds from over 1 minute). My laptop is a 2012 model Acer (E1-531). OS is presently Ubuntu 20.04. The SSD is a Seagate BarraCuda Q1 240GB. I made a 100 GB partition for root and rest for home.
    – Sri
    Jun 2 at 4:47

If you are using a recent version of Ubuntu Desktop, you can configure this pretty quickly using dconf-editor. Here's how:

  1. Install dconf-editor if it is not already present:

    sudo apt update
    sudo apt install dconf-editor
  2. Open dconf-editor:

    Open the Editor

  3. Click the magnifying glass to start a search, and type "sleep-inactive":

    dconf-editor Search Results

  4. Edit the sleep-inactive-ac-timeout value to 1800 (30 Minutes):

    Sleep Inactive AC Timeout

  5. Edit the sleep-inactive-ac-type value to shutdown (or something else you might prefer):

    Sleep Inactive AC Type

  6. Be sure to save your changes.

That's all there is to it.


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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.