Friday, May 1, 2009

Auto Shutdown my EeePC

Today I continue to work on how to auto shutdown my EeePC.

One possibility is to use the "Task Scheduler" of kde (Advanced Desktop), but this only allows you to specify a time delay (in seconds), and only 1 command to be executed.

Please note that you have to run the fastshutdown script as root, i.e. add sudo before the command.

In the Easy Mode simple desktop of my EeePC 4G with icewm start menu enabled, the "Task Scheduler" can be run from the Programs menu as follows:

Alternately, you can simply run the command "ktimer".

Shutdown my EeePC with the "at" command

To be able to specify a certain date/time to shutdown my EeePC, I looked for other possibilities.

One possibility is to use crontab, which come installed by default. But since this is only for a 1 time job, using crontab is not a good idea. So I turned to the "at" command which is not installed by default, but can be easily installed from the Xandros4 or Debian etch repositories.
/home/user> apt-cache policy at
at:
Installed: (none)
Candidate: 3.1.10
Version table:
3.1.10 0
500 http://xnv4.xandros.com etch/main Packages
500 http://ftp.debian.org etch/main Packages
500 http://ftp.us.debian.org etch/main Packages
3.1.8-11 0
500 http://www.geekconnection.org xandros4/main Packages
After you have enabled either of these repositories, you can proceed to install the package "at".
/home/user> sudo apt-get install at
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
courier-authdaemon courier-authlib courier-authlib-userdb courier-base courier-mta
Suggested packages:
courier-doc
The following NEW packages will be installed:
at courier-authdaemon courier-authlib courier-authlib-userdb courier-base courier-mta
0 upgraded, 6 newly installed, 0 to remove and 287 not upgraded.
Need to get 1736kB of archives.
After unpacking 4678kB of additional disk space will be used.
Do you want to continue [Y/n]? y
There will be a message box asking about configuring web-based administration. I think this is optional. Answer [Yes] only if you want to shutdown your EeePC from another computer.

Now to shutdown my EeePC with the command "at", here is what I have figured out:
/home/user> sudo atd
/home/user> at 1246
warning: commands will be executed using /bin/sh
at> sudo fastshutdown.sh
at>
job 11 at Sat May 2 12:46:00 2009
/home/user>
Basically, the steps are:
1) Run the at daemon as root (sudo atd)
2) Run the at command with a specified time, e.g. at 1246 (i.e. at time 12:46)
3) At the at> prompt, enter the command(s) to be run
4) Press [Ctrl]-[D] when you are done

If you want to cancel a pending job:
1) Use the "atq" or "at -l" command to list pending jobs
2) Note down the pending job number
3) Cancel it with the command: atrm [job number]

See http://www.computerhope.com/unix/uat.htm for more details.

No comments:

Post a Comment