Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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.

share|improve this question

marked as duplicate by Radu Rădeanu, Raja, Mitch, Alaa Ali, Jorge Castro Sep 18 '13 at 18:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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: – ahcox Feb 12 '15 at 15:48

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

sudo apt-get install xprintidle

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

if [ $idle -gt 1800000 ]; then
    shutdown -h now

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.

share|improve this answer
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

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