Script to kill stranded/orphan process by users.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to kill stranded/orphan process by users.
# 1  
Old 03-06-2002
Question Script to kill stranded/orphan process by users.

I have customers on our AIX/UNIX node startup a process that becomes stranded or orphaned and must be killed. I would like to create a script to check for these orphan processes and kill them. I can have cron run this job. The customers process will run and after 24 hours time out leaving an orphan process. I would like to have the script kill them after 24 hours. Thanks in advance for any help you can provide.

rjohnson :-(
# 2  
Old 03-07-2002
By orphan, do you mean zombies? If so, you can't kill them.
If they're simply going to run forever, you might look into something like idled:
http://www.darkwing.com/idled/

Hope this help, and please search the forums for more information.
# 3  
Old 03-07-2002
You have to know your applications fairly well to do this automated.
We are on digital unix.
Do you have a common parent process that launches the child processes that you want to kill ??
We have "captive" users that log in through a main menu script. If you have something like this, you can use ps -ef to grep for processes where initial login parent script is gone.
Many times our processes end up reverting to uid 1 under root and that makes it very easy to cleanup by grepping on the known process name and checking to see if the parent is uid one. (when it shouldnt be uid 1)
Hope this helps.
# 4  
Old 03-07-2002
Power

I do a ps -ef|grep on the program name and then I use the kill command on the parent process id. I only kill the ones that go from a time only stamp to a date stamp like Mar 6. I do this daily and over the weekend I have about 25 processes to kill on Monday. I will look into IDLE and see if this is an option. Thanks for your help.
# 5  
Old 03-07-2002
This is one of my scripts.....

#! /bin/sh
KILLLOG=/tmp/killlogfor PID in `ps -ef | grep -v root | grep processname | awk '{print $2}'`
do
echo killing $PID
kill -9 $PID
done

This is another that also kills message queues:

for PID in `ps -ef | grep -v root | grep -v proccessname | grep -v userid | grep " 1 " | awk '{print $2}' `
do
echo killing $PID$TEST
kill $PID
for QID in `ipcs -qp | grep -w $PID | awk '{print $2}'`
do
echo removing $QID$TEST
ipcrm -q $QID
done

Hope this helps...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Is orphan process handling by Solaris os and Linux os same?

In solaris, orphan process is put to sleep mode and does not consume any CPU resources. In Linux, orphan process is kept in running state consuming all CPU and Ram resources. Is it the case? Is there a difference on how these operating systems will handle orphan processes? The route cause of... (10 Replies)
Discussion started by: Belure Pooja B
10 Replies

2. Shell Programming and Scripting

Cannot kill hacker process with my script

I want to kill a process of xterm that is run by hacker with my login name. So, I write a shell script to do my goal. I run 2 xterm and then I run my script on a first xterm. it should kill the process of a second xterm but it doesn't.Why? Here is my code : #!/bin/ksh myps=$(ps -f|grep... (7 Replies)
Discussion started by: thsecmaniac
7 Replies

3. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

4. Shell Programming and Scripting

Script to Kill a Process by Name...

Hello all... new to these forums and a bit of a newbie with linux aswell. I need to figure out how to write a shell script to kill a process by name as given to the script as an argument. I've got that part working OK, but i need to make sure that the script does not allow processes that are... (6 Replies)
Discussion started by: cannon1707
6 Replies

5. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

6. Shell Programming and Scripting

Script to kill process...

hello Bros, I need to write some script that i can put it on crontab which checks for a process X if running. If the process X is ruuning then take the PID and kill it or display message that says process X is not running. I am using AIX 5.3 Thanks guys.:b: (2 Replies)
Discussion started by: malcomex999
2 Replies

7. AIX

Script allows user to kill other users: I'd like to know HOW...

Hello list, Have a problem that's highlighting gaps in my knowledge; can you assist? We have a script that's tacked onto our trading application which allows branch managers etc. to kill off the sessions of other users at their branch. A menu option in the application spawns a shell running... (8 Replies)
Discussion started by: alexop
8 Replies

8. HP-UX

Is there a script available to kill Idle users

My max user parm is set to 1050. I'm currently at 1038 this is causing major slow downs on the server. I looking for a way log off "idle" user logins with out having to do it individually. :confused: (5 Replies)
Discussion started by: rfmurphy_6
5 Replies

9. Shell Programming and Scripting

Script to kill process

Hello guys, I have a process named monitoreo, with 'monitoreo start' my process start until i kill them, now i want to do 'monitoreo stop' to kill them. After 'monitoreo start' i have this process running: ps -af UID PID PPID C STIME TTY TIME CMD ati 10958 1495 ... (5 Replies)
Discussion started by: Lestat
5 Replies

10. Shell Programming and Scripting

kill process of other users

Hi, Can I kill process submitted by another uesr (say user1) if I'm not the su. If I got some previledges granted from user1, can I kill user1's process? Please advise? Thank you very much! Regards, Tse (4 Replies)
Discussion started by: tsesukfan
4 Replies
Login or Register to Ask a Question