ups定时轮询关机shell

1. 定时轮询gateway,如果unreachable则halt
#!/bin/bash
# Program:
#       Ping the gateway every 1 minute, if not reply shutdown the server.
# History:
#       2011-11-15 owen.chen First Release
ping 192.168.1.1 -c 1 -w 1 > /dev/null
RESPONSE=$?
if [ $RESPONSE != 0 ]; then
        halt
fi


2. 在crontab里配置定时任务
* * * * * root /home/admin/script/pollingTiming.sh

你可能感兴趣的:(linux,shell,ping,shutdown,ups)