Friday, January 25, 2008

How To Shutdown Linux on a Timer?

This is a relatively simple tip, but if you’re new to Linux you might not be familiar with it. I don’t believe there is a built-in feature for doing this within Gnome or KDE, but this uses the command line so it will work in any environment.
This is quite simple to implement. You will need to open the command line to use this, but don’t fear! You don’t need to know anything about how to use the command line. In fact, I’ll even tell you how to make a handy little button for this.

If you’re comfortable with the linux terminal, you might already know that you can type halt on the command line and your computer will immediately shut down. Well, halt has a sibling command called shutdown which has a little bit more intelligence and features built into it. Shutdown is the command that we’ll be using here. First you’ll need to bring up your terminal.
If you’re running Ubuntu go to Applications > Accessories > Terminal. Now you should have a command prompt. Here’s an example of the command if you want to shut down in 30 minutes:

sudo shutdown -h +30

Sudo means you need to temporarily become admin in order to shut down the system - so you will be prompted for your password. -h tells shutdown that you want to halt the system as opposed to restarting it. +30 means you’re specifying 30 minutes on the timer. The other way to specify the time is to say exactly what time you want the system to shutdown. It’s in 24-hour time, so if you want the system to shutdown at 9:30PM, here’s the command:

sudo shutdown -h 21:30

Again, this will probably ask you for your password. If you want to cancel the shutdown, you can try typing Ctrl+C in the terminal where you issued the shutdown, or if that doesn’t work then you can manually issue a shutdown cancel like this:

sudo shutdown -c

No comments: