Skip to content

Instantly share code, notes, and snippets.

@takeru
Last active April 24, 2022 23:47
Show Gist options
  • Save takeru/45cc11f604063729f877534354e1b14c to your computer and use it in GitHub Desktop.
Save takeru/45cc11f604063729f877534354e1b14c to your computer and use it in GitHub Desktop.
pingだめならreboot
#!/bin/bash
#PING_HOST=192.168.0.1
PING_HOST=$1
if [ -z "$PING_HOST" ] ; then
logger "PING_HOST missing."
exit 1
fi
ping -c 10 $PING_HOST
exitcode="$?"
# logger "check_ping exitcode=$exitcode"
if [ "$exitcode" == "0" ] ; then
logger "check_ping $PING_HOST OK."
exit 0
fi
logger "check_ping $PING_HOST NG. reboot..."
sudo reboot
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment