pingコマンドの結果をログファイルに収集する
#!/bin/sh #autoping.sh logfile='ping.log' if [ -z "$1" ]; then echo "Usage: autoping.sh hostname [hostname...]" exit 9 fi daytime="`date +"%b %d %H:%M:%S"` " while [ -n "$1" ]; do if ping -c 1 $1 > /dev/null; then echo "$daytime PING is reachable. Host \"$1\" may be alive." >> $logfile else echo "$daytime PING is NOT UNREACHABLE. \"$1\" may NOT BE AVILE." >> $logfile fi shift done