0

I am running Xubuntu 13.04, I got in the habbit of closing my Acer Netbook and forgetting about it for a week+. I open it up to find it has still been running. How do I set it to shutdown after 15 minutes of inactivity? I don't want to set it to lid close because I often get up and close the lid so kids don't get at it. Also, due to the sometimes long stretches I go without touching it, I would like to make sure it is completely shutdown.

I'm sure I'm just missing some little check box. I've never had a setup that didn't shut itself down, or wasn't able to with a few click.

I already Googled the question for a bit and wasn't able to get the keywords right to get a relevant answer.

  • This is not a duplicate. The poster asks for shutdown after a period of inactivity. The question linked to asks for shutdown after a fixed delay from right now. – ahcox Feb 12 '15 at 15:36
  • A nice GUI for this task: https://launchpad.net/complexshutdown – ahcox Feb 12 '15 at 15:48

1 Answers1

1

Install xprintidle. This tool gives the idle time of a user.

sudo apt-get install xprintidle

Make a script autoshutdown.sh which checks for the idle time and instructs the computer to shutdown if idle for 30 minutes.

idle=$(xprintidle)
if [ $idle -gt 1800000 ]; then
    shutdown -h now
fi

Make a cronjob for this that checks from time to time if the system has been idle for too long and if it has been idle for a longer than 30 minutes it will shutdown. Note that the cronjob has to be made for the root user.

muru
  • 197,895
  • 55
  • 485
  • 740
  • I also want to take into account any background jobs like backups and delay shutdown in that case. Can you expand the above to account for disk IO and CPU utilisation, and/or scanning running processes for a list that should keep the machine awake (unison, dropbox at > X% cpu utilisation, ...) and proxies for idleness like that? – ahcox Feb 12 '15 at 15:39