Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active August 29, 2015 14:03
Show Gist options
  • Save mjf/1ff2406fecc00e4e695b to your computer and use it in GitHub Desktop.
Save mjf/1ff2406fecc00e4e695b to your computer and use it in GitHub Desktop.
Record time until host is up
#! /bin/sh
# Record time until host is up
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Depends on the humantime script:
# https://gist.github.com/mjf/1079421#file-humantime
if [ $# -ne 1 ]
then
echo "Usage: ${0##*/} [host]"
exit 0
fi
s=`date +%s`
while :
do
if ping -qc1 "$1"
then
break
fi
done
e=`date +%s`
humantime "$((e - s))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment