给定运行ping -c 25 google.com | tee /home/user/myLogFile.log
输出文件/home/user/myLogFile.log
包含:
PING google.com (117.102.117.238) 56(84) bytes of data.
64 bytes from 117.102.117.238: icmp_seq=1 ttl=61 time=12.7 ms
64 bytes from 117.102.117.238: icmp_seq=2 ttl=61 time=61.1 ms
(...)
64 bytes from 117.102.117.238: icmp_seq=25 ttl=61 time=7.11 ms
--- google.com ping statistics ---
25 packets transmitted, 25 received, 0% packet loss, time 24038ms
rtt min/avg/max/mdev = 5.573/11.293/61.102/11.210 ms
如何限制日志文件中的最大行数,如果达到该最大值,文件将被重置并保存下一个输出?
答案 0 :(得分:1)
好的,我认为你可以这样做:
ping -c 25 google.com | tee >(split -d -b 100000 - /home/user/myLogFile.log)