Results 1 to 2 of 2
I am trying to write a shell script that will identify processes of a particular name and run by the user who executes the script. Once i identify the processes, ...
- 06-09-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 1
Shell Script to kill orphaned processes
I am trying to write a shell script that will identify processes of a particular name and run by the user who executes the script. Once i identify the processes, i need to kill the orphaned processes.
The following command helps me to find the processes but i am not sure how to kill the orphaned processes ( the second one listed if a orphaned process without a terminal and parent id being 1).
Can someone help me to write this logic in a shell script ?
TEST[46]
s -ef | grep $(whoami) | grep [Pp]rocess
testuser1 1637 32466 0 15:47 pts/2 00:00:01 testing
testuser3 14480 1 0 May26 ? 00:00:00 testing
I do not want to run as root and kill the processes. This script will run as monitor script for the main process and will periodically check for the existence of the main process and if it identifies an orphaned process, it will kill it.
- 06-09-2010 #2
You could use awk to pick up the PIDs as the second field in your output, then use kill to terminate them.
"I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote