Skip to content

Instantly share code, notes, and snippets.

@mybuddymichael
Created November 12, 2012 20:26
Show Gist options
  • Save mybuddymichael/4061665 to your computer and use it in GitHub Desktop.
Save mybuddymichael/4061665 to your computer and use it in GitHub Desktop.
#!/bin/sh
ip_address="$1"
ping -c 1 "$ip_address" > /dev/null
if [ $? -gt 0 ]; then
log_line="`date` : Ping to $ip_address unsuccessful, REBOOTING."
echo "$log_line" >> /var/log/ping-or-reboot
/sbin/reboot
else
log_line="`date` : Ping to $ip_address successful, not rebooting."
echo "$log_line" >> /var/log/ping-or-reboot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment