2

I'm trying to make a script that save the ping logs to .txt or .log file. To monitor if my connection is intermittent or not, I'm using this script:

$nohup ping 8.8.8.8 > timeout.txt &

Then when I check if its pinging:

$tailf timeout.txt

It's working! But when I stop the process by using:

$kill (process)

timeout.txt file is stop pinging but didn't show the statistic logs if I had any timeout or packet loss.

How to stop the ping and also showing the statistic?
Or do I have to add a script to my script?

manatwork
  • 31,277
oacebes
  • 23

1 Answers1

3
kill -SIGQUIT `pgrep ping`

to show statistics and do not stop ping.

kill -SIGINT `pgrep ping`

to show statistics as usual (e.g., when you press ctrl-c in terminal) and stop ping.

int
  • 574
  • For OS X it's SIGINFO. You can also press Ctrl-T if the process is in the foreground (or Ctrl-\ for SIGQUIT OSes). – Eric Boehs Jan 28 '15 at 05:28