Wednesday, September 3, 2008

Shutdown Timer

For exampl: shutdown at 20:00 o'clock

sudo shutdown -h 20:00 -H -P

sudo: admin rights
-h: hour:minutes
-H: hold system
-P: Power down

-c is very usefull when you need to cancel the shutdown


--------------------------------------------------------
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. Shutting down your computer on a timer can be useful if you want to do something like put on a music playlist, and then have your computer automatically turn off after an hour. Kind of like the sleep timer on your TV.

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

If you’re using Gnome, and you want to create a button for this, go up to your panel and right-click on it. Click “Add to panel.” Then click “Custom Application Launcher.” For type, specify “Application in Terminal.” Name it something like “Shutdown in 30 min.” For the command, use what you learned above. You can also find a pretty little icon for it.

See also: http://micrux.net/?p=42

Don't want the beeps?
You hear beep when you choose: sudo shutdown +10
so in ten minutes; you may hear a pc speaker beep every minute; this will be a annoying.
"The best way that I found to disable the system beep is to remove the kernel module that creates it. This has the advantage to turn off the PC speaker completely thats the speaker creating the beeps. It will work for all applications.

Execute the follow command in a terminal and try to see if you hear a beep:
Code:
sudo rmmod pcspkr
In order to always disable the speaker after each system boot add the following lines to the file /etc/modprobe.d/blacklist:
Code:
# No more beeps
blacklist pcspkr
source: http://ubuntuforums.org/showthread.php?t=531781
====================================================
Setting it up as an automated task

Howto Get Enough Sleep Despite StumbleUpon with Ubuntu

What?

I am a long-term StumbleUpon user, which means that I don’t get much sleep. Now, after almost 4 years of stumbling, I have decided to get my life back. Well, at least some sleep!

What does this do?

Every night when I have to work on the next day (Sunday night to Thursday night ), at 23:25 my computer shows me this little warning message:

go to bed warning

After the 5 minutes have passed, the computer shuts itself automatically down.

I use this little trick with Ubuntu, but it should work anywhere where Gnome is installed.

How?

Thanks to the power of Linux, this is not difficult to do for yourself, and configure it however you want it to behave:

  1. Open /etc/crontab with your favourite text editor (no need for crontab -e since this is the system wide crontab), e.g.
    sudo gedit /etc/crontab
  2. Add the following lines (replace manker with your username!)
    25 23 * * 0-4   manker  /usr/bin/zenity --display :0 --warning --text="Shutdown in 5 minutes. Go to bed."
    25 23 * * 0-4 root shutdown -h +5
  3. The first part of both lines 25 23 * * 0-4 means that the commands are executed at 23:25, but only Sunday (day 0) to Thursday (day 4). Read man 5 crontab for a detailed description of that format.
  4. The first command uses zenity to show a warning message. You have to execute this as the same user that you use for working, or you will not see the message, so change manker to your username (root does not work either).
  5. The second command shutdown -h +5 means that the computer will halt in 5 minutes. This has to be run as root, and it also shows nice warning messages in all your open terminals so you can’t really miss it.
  6. Save the file, and stumble until it is 23:25.

Sweet dreams!

1 comment:

pablo said...

Change shutdown -h +5 to
shutdown -H -P +5

Blog Archive

About Me

Exclusion of liability Regarding StillStupid: The use you make of the guides, tips and downloads that you listed on this web site or on another website to which I refer is entirely at your own risk. In no way can I be held liable for damage or consequential damages of any kind, which occurs as a result of that use.