Skip to main content
Welcome guest. | Register | Login | Post

Auto shutdown your computer in Linux

When going to sleep I sometimes like to leave my computer on playing ambient music from an internet radio station. It's a really good intro to the dreams. Smiling

However I don't want to have the computer play and be turned on all the time so I use a simple auto shutdown program to set the amount of time in which it should shut itself off.

There are two relatively similar and simple programs that do that, one suitable for KDE and another for GNOME (or Xfce). Both sit in your tray and count the time.


KShutdown allows you to set the exact date and time or "time from now" which is what I and likely you will want. Just set the time in hours or minutes and click ok. You can also set it to initiate when a certain application you select closes which may come in handy sometimes as well.

In addition to auto shutdown you can also set it to auto restart, hybernate, suspend (sleep), lock screen or logout. Even that's not all though. There's also an "extras" option which allows you to set a specific command such as stopping a particular program or terminate a connection. You can add more programs available for auto stopping as well.


GShutdown also allows you to set the date and time or time from now that has to pass for auto shutdown to be initiated and it can initiate auto restart or logout (end session) as well. It doesn't have the option to sleep or hybernate however.

In preferences you can select the method of shut down which may depend on which desktop environment (KDE, GNOME or Xfce) or display manager (kdm or gdm) are you using. You can also specify the exact command it should initiate before executing the auto shutdown, restart or logout.



Re: Auto shutdown your computer in Linux


I just wanted to push my own clone of GShutdown, that uses dbus for control. I built it as an intro project to learn python and ubuntu packaging. It is a gshutdown clone, so the interface is almost identical:

Re: Auto shutdown your computer in Linux


What about

$ echo halt |sudo at now + 2 hours


Dude, I did not know that we had a GUI for shutdown. I usually do sudo shutdown HH:MM. Thanks.

Re: Auto shutdown your computer in Linux



Re: Auto shutdown your computer in Linux


When I first started using Linux 2 years ago, I discovered sudo apt get to get my laptop to closethe way you describe and thought I was pretty l33t but it got old fast and have been using Kshutdown and it does what I need it to do.

Of course, the kids know how to extend the time too so Im hoping Kshutdown adds a password option so the kids dont tamper with it when you give them 15mins before going to bed.

The only other shutdown function I would need is when using Ktorrent, I would like it to be able to shutdown when DLs are done.

Re: Auto shutdown your computer in Linux


oh boy, what an overkill and waste of resources, 2 GUI's for doing a "shutdown -h +60" or the like. This over-GUI-ification sucks.

Re: Auto shutdown your computer in Linux


I usually go for
sleep 2h && halt
sleep 2h && pm-suspend

Thanks for all the other command line alternatives. Smiling

About over-GUI-ification it's for those who either aren't aware of or are too lazy to type commands in the terminal and I don't think a simple app like this is all that much of a burden on resources. If you don't like it, don't use it and it wont suck for you. Smiling



Also worth mentioning:

Personally, I mostly use "sudo shutdown -h HH:MM" or crontab with "shutdown -h now".
But I like the GUIs. Less to type. Smiling
And it offers the possibility to shut down when a specific program closes. Not sure where I can use this yet, but it might come in handy.

As for over-GUI-ification: Those that do not like GUIs are not forced to use them.

I gotta say gshutdown hasn't been working for me on Ubuntu 9.10 for some reason. It just logs out. Kshutdown has problems in GNOME too.

I find myself going back to this thread for those command line suggestions which I think are probably more reliable. So, thanks again guys for posting them! Smiling

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.