Excerpt |
---|
The below bash sh script trigger rebooting server if Google DNS does not respond |
Code Block |
---|
#!/bin/bash
target="sh
ping -w 10 -c 1 8.8.8.8
if [ $? = 0 ]
then
echo noreply
else
/sbin/reboot
fi |
In the AsusWrt, the below script works good
Code Block |
---|
language | bash |
---|
title | /jffs/scripts/reboot_if_ping_does_not_work |
---|
|
#!/bin/ash
if [ "
count=$( ping -c 1 $targetgoogle.com | grep icmp*ttl | wc -l )
if [ $count -eq 0 ]
then
date >> /home/user/pingfail.txt
/sbin/shutdown -r now
else
date >> /home/user/pingsuccess.txt echo noreply
/sbin/reboot
else
echo "google.com is reachable"
fi |