kill a running process
Hello everybody,
I trying to kill one process but only if the process is running, what I tried to do was that: list=`ps x | grep crttool | grep -v grep | awk '{print $1,$3}'` With that I can retrieve the pid and the status, but for every process in one string. Who could I see if the status is running (R) and kill it. There's a way to send the awk exit to one array? or a better way? thank's Carlos |
What does "exit to one array" mean?
Ayway, what's wrong with "killall"? Code:
killall crttool |
Quote:
I can't do that, because the problem is if the process is running, i could figure out the solution, by doing this: toKill=`ps x | grep process | grep -v grep | awk '/R/ {print $1}'` the problem is that process is running like a ghost the application is closed but still running. It's a TCL application Thanks! Carlos |
This lists the processes and kill them:
Code:
ps -C command -o pid,state --no-headers | awk '/S/{print "kill -9", $1 | "/bin/bash"}' |
Quote:
Code:
system("kill -9 " $1) |
All times are GMT -5. The time now is 10:29 AM. |