放后台运行命令:setsid
实时输出命令:unbuffer
加时间戳:awk ‘{ print $0"\t" strftime("%D_%H:%M:%S",systime()) } ‘
命令如下:setsid unbuffer ping 172.17.1.1 -i 2 | awk ‘{ print $0"\t" strftime("%D_%H:%M:%S",systime()) } ‘ >> test.txt
但是这样有问题,无法放入后台
最后把 ping 172.17.1.1 -i 2 | awk ‘{ print $0"\t" strftime("%D_%H:%M:%S",systime()) } ‘ 放入脚本ping-test.sh
运行:setsid unbuffer ping-test.sh >> test.txt 正常~~
时间: 2024-11-02 12:13:14