LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shutdown and starting my box at prespecified time (https://www.linuxquestions.org/questions/linux-newbie-8/shutdown-and-starting-my-box-at-prespecified-time-361661/)

umeshbabu 09-09-2005 01:57 AM

shutdown and starting my box at prespecified time
 
Hello,

how can i shutdown my box at night 10:00 pm and automatically it should start at morning at 8:00 am.

how can i do this.

i can see command for shutting down box at specified time but how to start at specified time?

thanks for your time

morrolan 09-09-2005 06:16 AM

I don't know how you are going to do this.

Obviously, you can set a shutdown time easily enough - when your computer starts, you should also get it to run a bash script which contains your shutdown command (see man (8) shutdown).

The following has to be run as root unless you give yourself sudo permissions. (man sudo)

Code:

#!/bin/bash

####  Shutdown code

sudo shutdown 22:00 The system is going to shutdown automagically at 10pm!

cp /etc/nologin nologin_backup
rm /etc/nologin

This would probably need to be run in the background to avoid wasting a terminal.

Also, I do not vouch for how safe deleting the /etc/nologin file is - this is created if the shutdown command is issued with any kind of delay, whether a countdown or a preset time, and it's purpose is to not allow anyone to log in once a shutdown command has been issued. You might be ok if this script is run from your .bashrc or .bashprofile, as these are executed once you login, so as long as you don't log out before 10pm you're fine.

As for booting at a specific time - I have no idea unless you can do it through some kind of suspend/resume function, rather than a complete shutdown.

I suppose you can always set an alarm clock for 8:00am and then train your cat to press the power button! :D

logosys 09-09-2005 09:50 AM

Unfortunately, there isn't a way to have the operating system turn the computer on (can you imagine the chaos that would ensue?) so you have two options:

A) Concoct a Rube Goldberg Machine that is actuated by an alarm clock. When the clock hit's 8, it drops a ball that flips a lever that launches a ball into the air (insert other operations here) that pushes a rod that turns the computer on. (Rube Goldberg Tips) I don't recommend this.

B) Alternatively, you can have another computer on your network send a WOL (Wake on LAN) signal to your computer. I've used ether-wake for this purpose, it works very well. It has really good Documentation. You can download the source for it from Scyld's website: .c file

Hope this helps.


All times are GMT -5. The time now is 12:54 AM.