![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shutdown script | kingsto88 | HP-UX | 0 | 03-20-2007 05:43 PM |
| A script for shutdown | kelu | UNIX for Dummies Questions & Answers | 12 | 08-23-2006 06:09 PM |
| Script not waiting for user responce | rdudejr | Shell Programming and Scripting | 3 | 07-05-2006 08:20 AM |
| Shutdown script | alpha_manic | UNIX for Advanced & Expert Users | 10 | 09-14-2005 01:14 PM |
| logout/shutdown script | ropers | UNIX for Dummies Questions & Answers | 1 | 08-02-2002 11:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with script, shutdown if no ping responce
Hi, i would like to create a script that shuts down the system if the power fails, basicly the solaris box would load the script at startup.
Ping 192.168.1.100 every 20 secs If cannot get responce 3 times in a row send init 0 to the system. Simple but effective, as 192.168.100.1 wont be on the ups backup, so the solaris system will know the power is down and it will shutdown. Im sure it wont be hard to do im just new to unix, could someone help me with this? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
anyone?
|
|
#3
|
|||
|
|||
|
Erm........
If I am reading this right.....you want to send a shutdown command to a machine, the power to which, has failed. If the power has failed the machine will be dead in the water and not be able to respond to *any* commands. Have you described your requirement clearly and accurately as at present, unless I have badly misread it, it doesn't make a whole hep of sense |
|
#4
|
|||
|
|||
|
I have a unix machine which is on a UPS with only about 15mins battery life, what i would like to happen is the unix machine shutdown safely if the power fails. The way i want to do it, would have the unix machine ping my cable modem every 20 secs, which is not on the UPS, so if the ping was to have no responce the modem would probably be off, which means the power would have failed.
I would like the unix machine to shutdown if it cant contact the cable modem 3 times in a row via ping. |
|
#5
|
|||
|
|||
|
Code:
#!/bin/sh
while true
do
sleep 300
REBOOT=/usr/bin/true
for d in a b c
do
if /usr/sbin/ping cable-ip
then
REBOOT=/usr/bin/false
break
fi
done
if $REBOOT
then
shutdown -g 1 -y -i 5
fi
done
Note, Solaris "ping" works quite differently to other platform pings. |
|
#6
|
|||
|
|||
|
Thanks! would this work with solaris 10?
|
|
#7
|
|||
|
|||
|
Give it a go....
Make sure you understand it all before you install it, as it has to run as root to run shutdown. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|