I'm writing some automation scripts, in which I need to kill some processes.
Previously I would usually use kill -9 pid
to kill processes but once upon a time, I notice that when I used kill -9
to kill some tcpdump
processes:
For example:
tcpdump -i eth0 -w output.pcap
The captured packets were not put into output.pcap
and it was empty. But if I used kill
, it worked fine.
For some processes, like ./prog >> test_log
, I'm afraid if I use kill -9
to kill the processes the output won't get redirected to test_log
.
I'm also afraid if I use kill
without -9
the kill command may fail.
Can anyone tell me how to properly use kill
so that the killing doesn't cause problems with the output file and I'm able to kill the processes without issue?