Linux (Tested on Ubuntu 20.04)
Send the SIGQUIT
signal.
Example output:
64 bytes from localhost (127.0.0.1): icmp_seq=138 ttl=64 time=0.021 ms
64 bytes from localhost (127.0.0.1): icmp_seq=139 ttl=64 time=0.022 ms
139/139 packets, 0% loss, min/avg/ewma/max = 0.014/0.022/0.022/0.057 ms
64 bytes from localhost (127.0.0.1): icmp_seq=140 ttl=64 time=0.090 ms
64 bytes from localhost (127.0.0.1): icmp_seq=141 ttl=64 time=0.025 ms
Send while running
CTRL+\ = quit
according to stty -a
.
These also work: CTRL+|; CTRL+4;
Send to one or more known pids
kill -SIGQUIT <pid> [...]
Send to all running
ps -o pid= -C ping | xargs -r kill -SIGQUIT
Periodically send to all running
while sleep 20; do ps -o pid= -C ping | xargs -r kill -SIGQUIT; done
As a background job
while sleep 20; do ps -o pid= -C ping | xargs -r kill -SIGQUIT; done &
FreeBSD (Tested on pfSense 2.4.5, based on FreeBSD 11.3)
Send the INFO
signal.
Example output when sent via CTRL+T:
64 bytes from 127.0.0.1: icmp_seq=137 ttl=64 time=0.328 ms
64 bytes from 127.0.0.1: icmp_seq=138 ttl=64 time=0.028 ms
load: 0.18 cmd: ping 62483 [select] 144.69r 0.00u 0.01s 0% 2256k
139/139 packets received (100.0%) 0.018 min / 0.072 avg / 0.505 max
64 bytes from 127.0.0.1: icmp_seq=139 ttl=64 time=0.116 ms
64 bytes from 127.0.0.1: icmp_seq=140 ttl=64 time=0.027 ms
Example output when sent via kill
:
64 bytes from 127.0.0.1: icmp_seq=137 ttl=64 time=0.328 ms
64 bytes from 127.0.0.1: icmp_seq=138 ttl=64 time=0.028 ms
139/139 packets received (100.0%) 0.018 min / 0.072 avg / 0.505 max
64 bytes from 127.0.0.1: icmp_seq=139 ttl=64 time=0.116 ms
64 bytes from 127.0.0.1: icmp_seq=140 ttl=64 time=0.027 ms
Send while running
CTRL+T = status
according to stty -a
.
Send to one or more known pids
kill -INFO <pid> [...]
Send to all running
ps -o comm= -o pid= | egrep '^ping[[:space:]]' | awk -F' ' '{print $2}' | xargs -r kill -INFO
Periodically send to all running
printf "while ({ sleep 20 })\nps -o comm= -o pid= | egrep '^ping[[:space:]]' | awk -F' ' '{print \0442}' | xargs -r kill -INFO\nend\n" | tcsh
As a background job
printf "while ({ sleep 20 })\nps -o comm= -o pid= | egrep '^ping[[:space:]]' | awk -F' ' '{print \0442}' | xargs -r kill -INFO\nend\n" | tcsh &
Notes and Thanks
Thank you @pmos for your answer which seeded my idea for the periodic method in the first place, and to all the other answers and comments which contributed to this one.
Thank you @VictorYarema for making the suggestion that I turn my comment into an actual answer. The essence of the method in the original comment is the same, but has evolved over time as follows:
- Added the
-r
option to xargs
to prevent it from running kill
without a pid when there are no results from ps
- To get rid of the header row in
ps
I used the -o pid=
option to set the column header text to empty instead of h
since h
has different meanings for Linux and FreeBSD
- While
ps
supports the explicit --no-headers
option in Linux, the same is not true for FreeBSD
- Moved the
sleep
command into the while
test condition
- Removed unnecessary quotes
- Ported to FreeBSD