Linux – log ping command results with time and date

If you have a need to test that a link is stable between servers

e.g. between an MBG and a Micollab

you can use his command to log the results of the ping command to a log file

ping -i 5 10.150.0.5 | xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' > test.txt

It also adds the time and date of the ping to every line which is needed if you need to check what happened at a certain time.

Output example:

I use the “screen” command to leave this running  with out the need to stay connected with the console.

You can use “tail -F filename” to watch the file filling up and current ping times

 

Leave a Reply

Your email address will not be published. Required fields are marked *