the network frequently fails and I would like to monitor the output. I tried to makeshift a command like:
ping www.google.fr | while read pong; do echo "$(date): $pong"; done 1>/dev/null && 2> ~/ping_err.log
but the STDERR is still redirected to STDOUT instead ping_err.log
note: I want only STDERR in the file (not 2>&1)
Thanks!
Rather than answer your
stderr
redirection question, I'll suggest a better (IMHO) way:In
https://github.com/waltinator/net-o-matic.git
- Watch for (WiFi) network going down, then do a user-specified thing to fix it.There's a way to monitor your connection:
My
net-o-matic
script also contains a way to ask once:Using your code, this seems to work:
I expanded @schrodigerscatcuriosity's answer a bit with:
-i 10
wait 10 seconds before sending each packet-O
for logging outstanding ICMP ECHO reply before sending next packet-q
for quiet output (except for timeouts)| tee
to simultaneously print the output to console and file