IsraelTorres icon

loghost.sh

IsraelTorres | PRO | 10/25/12 03:05:51 PM UTC | 0 ⭐ | 502 👁️ | Never ⏰ | []
Bash |

460 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
# ./loghost.sh
# Israel Torres 20121025 host site logger - pings host and logs when it came back up
ltimestamp=$(date +%s)
ltsreadable=$(date -r $ltimestamp)
HOST=$1
echo "Scanning:: $HOST as of [$ltimestamp] $ltsreadable ..."
ping -o $HOST > /dev/null
if [ "$?" = 0 ]; then
    timestamp=$(date +%s)
    tsreadable=$(date -r $timestamp)
    echo "$HOST appears UP as of [$timestamp] $tsreadable ***" | tee "log-$timestamp-$HOST.txt"
else
    echo "weird error"
fi
#eof

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎