How do I make DSL shut down at a certain time?


Forum: Other Help Topics
Topic: How do I make DSL shut down at a certain time?
started by: arew264

Posted by arew264 on May 06 2005,21:39
OK, I have a question. How would I go about setting up DSL to shut down at say... 7:30 PM. My computer clock is set right. I believe I have cron installed from a debian package. I am running apache and a website on an old pentium comp that runs well and does what it should. THis is an older computer that doesn't turn off on it's own because you have to hit the poser button (the power button is really a switch). I'm planning to put a timer on the surge protector so the following will occur:
6:00 AM timer turns on surge protector and computer turns on
7:30 PM computer turns off
7:40 PM timer turns off surge protector to complete the shutdown

I can get a timer, but how do I schedule a shutdown?

Posted by Caspar_s on May 06 2005,23:13
Google help cron
and linux shutdown.

If dsl has "shutdown" you can put the time in that, but for regular use, cron would be best I think.

Posted by arew264 on May 06 2005,23:23
you mean putting a shutdown command in the bootlocal.sh and setting the seconds to the huge number representing the time when it should turn off? that would work...

THanks for your help. Any other ideas appreciated while I play with this.

Posted by clacker on May 07 2005,16:11
EDIT: reread message and revised answer

You need to make a crontab file.  To do this, open a bash shell and type:

export VISUAL=beaver

to use beaver as your crontab editor.  You could use any editor you want.  Now edit a crontab file by typing crontab -e  Here is an example crontab file that shuts down every day at 8:00:

Code Sample

30 19 * * * sudo shutdown

# minute (0-59 or *)    30 = minutute = 30
...# hour (0-23 or *)  19 = 7 PM
......# day (1-31 or *)  * = everyday
........# month (1-12 or *) * = every month
...........# day of week (0-6 6=Sunday) * = every day of the week

view your crontab file using crontab -l

Posted by SaidinUnleashed on May 07 2005,17:26
You will also need to install a cron server, because DSL doesn't have one.

Use the search function at packages.debian.org to look at the different available crons and choose one that will suit you.

Posted by arew264 on May 08 2005,16:44
I edited my crontab and installed cron, I'll be back in a min to see of it works...
Posted by arew264 on May 09 2005,01:51
hmmmm. I'm lost. at about 8:40 by my clock on May 8, I set up crontab as follows:

45 20 * * * sudo shutdown -n -h -t secs now

Wouldn't this have turned the computer off at 8:45? The shutdown command doesn't work alone, so I made it skip init (very fast) halt linux, and do it instantly. Why did this now work?

For your reference, I downloaded this debian package for the cron server:

cron_3.0pl1-87_i386.deb

which I got from < here >
Did I get the wrong package or program crontab wrong?

Posted by mikshaw on May 09 2005,03:16
the shutdown command requires arguments, at the very least whether you want to halt or reboot the system.  For halt you need to specify when, such as "sudo shutdown -h now".
DSL has an alias for this: "sudo halt"

Posted by skaos on May 09 2005,11:20
Normally you have to use the full path of the commands in cron jobs:
45 20 * * * /full/path/to/sudo /full/path/to/shutdown -n -h -t secs now

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.