![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shutdown script | kingsto88 | HP-UX | 0 | 03-20-2007 08:43 PM |
| A script for shutdown | kelu | UNIX for Dummies Questions & Answers | 12 | 08-23-2006 09:09 PM |
| Script not waiting for user responce | rdudejr | Shell Programming and Scripting | 3 | 07-05-2006 11:20 AM |
| Shutdown script | alpha_manic | UNIX for Advanced & Expert Users | 10 | 09-14-2005 04:14 PM |
| logout/shutdown script | ropers | UNIX for Dummies Questions & Answers | 1 | 08-02-2002 02:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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? |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
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. |
![]() |
| Bookmarks |
| Tags |
| ping, ping port, port, port ping |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|