Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active October 30, 2020 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-minguez/42698c72e216af4f00c160d3ef0082c5 to your computer and use it in GitHub Desktop.
Save e-minguez/42698c72e216af4f00c160d3ef0082c5 to your computer and use it in GitHub Desktop.
#!/bin/sh
TIMES=4
HOST=$(ip route show default | awk '/default/ {print $3}')
/bin/ping -c${TIMES} ${HOST} > /dev/null
if [ $? != 0 ]
then
/sbin/shutdown -r now "No connectivity to ${HOST}, rebooting..."
fi
# Then in crontab
#*/5 * * * * /root/pingordie.sh > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment