Delete output PIDs
Hi
lsof +D /root/test/ I want to delete all the PID comes from lsof command output (in below case PID 6356,6986,8184) COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME vi 6356 root 4u REG 8,3 12288 263637 /root/test/.test.txt.swp vi 6986 root 4u REG 8,3 12288 263793 /root/test/.test1.txt.swp vi 8184 root 4u REG 8,3 12288 263904 /root/test/test/.test1.txt.swp Please help me |
Hi
I guess below is pretty good kill -9 `lsof +D /root/test/ -t` Please share your answers if still there is easiest way |
If number of processes to be killed is many then kill command may fail just because command line length overflow.
So this may do the job: Code:
for pid in `lsof +D /root/test/ -t`; do |
Thanks Veerain
|
do not use kill -9, but a simple kill (use only -9 if otherwise did not work).
For example in your case kill -9 will obviously kill the process vi, but the file /root/test/.test.txt.swp will not be deleted. Using kill without -9 will allow to delete that file. |
What pan64 said is right.
kill -9 used to terminate program immediately. It does not allow a program to do some cleaning, saving or other tasks a program normally does when exiting. whereas kill -15 allows a program to do tasks it normally does when exiting gracefully. |
All times are GMT -5. The time now is 04:18 AM. |