ping命令添加时间戳

ping 192.168.0.1 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) }'

PING 192.168.0.1 (10.37.190.10) 56(84) bytes of data.    16:24:25
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.693 ms    16:24:25

把信息输入到文本

ping 192.168.0.1 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) }' > ping.log


把任务放到后台运行

ping 192.168.0.1 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) }' > ping.log &

你可能感兴趣的:(linux)