The ping results written to the file

Write a sh file:

#!/bin/bash
while true
do
    echo `date +"%Y-%m-%d %H:%M:%S";ping -c 1 $1|grep -i from 2>&1`
    sleep 1
done

 

Save as ping.sh, Fu executable permissions:

chmod +x ping.sh

carried out:

./ping.sh 192.168.1.6 > ./1.log

Guess you like

Origin www.cnblogs.com/lavezhang/p/11716125.html