I'm starting a tcpdump
inside a script and I also kill it from the same script. So I'm currently using the killall
command for this: The script gets executed from an udev
rule: This is the section, which should terminate the tcpdump
: In addition I also use -s SIDKILL
, because I've read that this could also help.
What is the problem that killall
doesn't terminate the tcpdump
. When I start the script manually it is all working properly.
if [[ "$pid1" != "" ]];then
sudo killall -s SIGKILL tcpdump
sh /tmp/scripts/autoumount.sh &
sudo kill -9 $$
echo "autodump stopped"
Since you're starting tcpdump from the same script, there's no need for killall
.
If you're running multiple background processes, use an array, like so:
pids=( ) # initialize empty array
tcpdump & pids+=( "$!" ) # extend said array
...later on, you can kill those PIDs:
kill "${pids[@]}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.