Way to shut the PC down at a specific preset time?

Daniel Carrera daniel.carrera at zmsl.com
Thu Apr 20 13:04:09 UTC 2006


Anthony D. wrote:
> Is there a way to make Ubuntu shut a PC down automatically at a preset
> time each day? All I can find so far is the screensaver's "shut off
> after x minutes" function, which isn't what I'm looking for... thanks!

I only know of one way, and that's to setup a cron job:

sudo gedit /etc/crontab

Crontab looks like this:

17 *	* * *	root    command1
25 6	* * *	root	command2
47 6	* * 7	root	command3
52 6	1 * *	root	command4

The first 5 columns denote how often you want the command to run, the 
second column is which user should run it, and the last column is what 
command to run. The first 5 columns are, in order:

* Minute (0-59)
* Hour (0-23)
* Day of month (1-31)
* Month of year (1-12)
* Day of week (0-7)

If you put a * it means "all".

So, for example, to have the computer shut off at 2:30AM each morning, 
you would use:

30 2 * * * root  shutdown -h now

The first two colums mean "2:30". The next three mean "every day of the 
month, every month of the year, every day of the week". The command must 
be run by root. And the command is "shutdown -h now". The -h flag means 
"power off the computer at the end", which is what you want.

Hope that helps,
Daniel.
-- 
      /\/`) http://opendocumentfellowship.org
     /\/_/
    /\/_/   A life? Sounds great!
    \/_/    Do you know where I could download one?
    /




More information about the ubuntu-users mailing list