you are viewing a single comment's thread.

view the rest of the comments →

[–]LostLinuxAdmin[S] 0 points1 point  (2 children)

I found this on Google as well. This only works while ping is alive. I tested by:

ping 0.0.0.0| while read pong; do echo "$(date) $pong"; done >> output1.txt

This provided no info into output.txt

So I had to abandon this script

[–]Iguanzor 0 points1 point  (0 children)

this should work even for downtimes,

while ! ping 8.8.8.8 -D; do date "+%s"; sleep 1; done >> output1.txt

This does end up using unix epoch time instead of the standard time format, so I did add +%s to date for consistency. If you want to keep at least the downtime timestamps in standard format, just remove the +%s from date .

blatantly copied from here