Skip to content

Instantly share code, notes, and snippets.

@hugo
Last active January 17, 2018 11:27
Show Gist options
  • Save hugo/a9d4864c6b4b20629da3ba61a03a4769 to your computer and use it in GitHub Desktop.
Save hugo/a9d4864c6b4b20629da3ba61a03a4769 to your computer and use it in GitHub Desktop.
#!/bin/bash
log_file="/var/log/am_i_up.log"
log() {
echo "$(date) $1" >> $log_file
}
if ping -c 1 8.8.8.8 > /dev/null 2>&1; then
log "network up"
else
log "network down"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment