[K12OSN] OT: Shutdown Linux from Windows?

Doug Simpson veewee77 at alltel.net
Tue Sep 5 22:40:09 UTC 2006


Here is a possibility. . .

Ping the winders box (the one from which you want to shut down the linux 
server) and outputs to a file.

example:
[server]$ ping -i 5 servername >> /pingreturns
This pings the server every 5 seconds. Change the number to whatever 
resolution you want.
Run this fron a cron job at a time a bit after you expect the winders 
computer to be online, say half an hour after. (or you could put it in 
the rc.local so it will run when the server is started, just make sure 
the winders one is up enough to reply to ping requests or the linux will 
go back down again.)
Run a second cron job that runs every minute (or whatever resolution you 
prefer) that
greps this outut file for a string stating that the pinged hosts is 
unreachable:

grep reply /pingreturns and if it finds "reply from" then exit.

If it finds "unreachable" branch and delete the /pingreturns file
and then run "shutdown -h now".

The grep line is the one I will need help with the syntax and it may 
actually have to be done in a script that would run in the cron job.

What this will do is ping the winders computer. If it returns, all is 
well. If it is unreachable, delete the /pingreturn file (so it won't try 
to use it tomorrow and find "unreachable" in there and shut right back 
down again) and then shutdown the linux computer with:
shutdown -h now
in the script.

Assuming this is a daily thing, you will only need to shutdown the 
winders one and the linux will soon follow it based on your resolution 
as mentioned above.

I will try to play with the grep thing later and see if I can come up 
with a workable solution for you.

Hope this is what you were looking for.

Doug





Onatawahtaw wrote:

>Greetings,
>
>Currently I can shut down all my windows computers
>using psshutdown.exe (and a batch program). Is there
>any way I can shut down linux computers from within
>windows? 
>
>If not, how can I shutdown remote linux computers from
>within linux? All the linux computers use the same
>root password so I would like to just put them in a
>shell script.
>
>Thanks,
>
>-Kevin
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>_______________________________________________
>K12OSN mailing list
>K12OSN at redhat.com
>https://www.redhat.com/mailman/listinfo/k12osn
>For more info see <http://www.k12os.org>
>
>  
>




More information about the K12OSN mailing list