Given a bash script running ping -c 25 google.com | tee /home/user/myLogFile.log
And the output file /home/user/myLogFile.log
containing:
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
How to limit the maximum lines in the log file, and if that maximum is reached, the file is reset and keep the next output saved?
Ok, I think you can do something like:
ping -c 25 google.com | tee >(split -d -b 100000 - /home/user/myLogFile.log)