I use iptraf to monitor the network traffic in linux, and the shell command is(make iptraf running in background):
iptraf -s eth0 -f -B -L ./traffic.dat
if I want to get the result, I have to stop iptraf first, so I use the shell command:
kill -SIGUSR2 $pid
however, I could not stop iptraf if I move these shell commands into a bash script file(net.sh), and I get an error:
kill: SIGUSR2: invalid signal specification
I use 'kill -l' in the script file(net.sh), and I find there is no parameter which name is SIGUSR2. and I would get nothing if I use USR2 or -9.
the complete script file is:
iptraf -s eth0 -f -B -L ./temp.txt
pid=`ps -ef | grep iptraf | grep -v grep | awk '{print $2}'`
kill -USR2 $pid
cat temp.txt
I get nothing after these commands.
what shoud I do if I want to get the result?