- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- auto kill of runaway processes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 09:49 AM
тАО05-01-2002 09:49 AM
auto kill of runaway processes
Anyone have thoughts or script out there that might fit the bill? Getting sick of killing these by hand. Many users rotate through our platform here and I try to explain exit protocol but these happen every day... if left too long...they really drop the performance level.
Thanks.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 09:50 AM
тАО05-01-2002 09:50 AM
Re: auto kill of runaway processes
- Tags:
- zombie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 09:54 AM
тАО05-01-2002 09:54 AM
Re: auto kill of runaway processes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 09:57 AM
тАО05-01-2002 09:57 AM
Re: auto kill of runaway processes
You should be able to kill these based on your criteria then, here's some pseudocode:
1) I'd build a list of processes, call it 5_min_list.
sleep 5 minutes
2) check to see if the processes in your five minute list are still running, if they are kill them.
3) restart at step 1.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 10:03 AM
тАО05-01-2002 10:03 AM
Re: auto kill of runaway processes
while true
do
ps -eaf | grep defunct | awk '{print $2}' > PIDS
sleep 300
for PID in `cat PIDS`
do
IS_IT=`ps -eaf | grep $PID`
if [ "${IS_IT}" = '' ]
then
echo "no longer running"
else
kill $PID
fi
done
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 10:04 AM
тАО05-01-2002 10:04 AM
Re: auto kill of runaway processes
can you post the ps -ef|grep output of what you get killing each time?
If you want to kill by program name you can do:
#!/bin/ksh
pid_var=`ps -ef | grep program_name | grep -v grep | awk '{print $2}'`
kill -9 $pid_var
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 10:13 AM
тАО05-01-2002 10:13 AM
Re: auto kill of runaway processes
This may help:-
-----------------caut-------------
#!/bin/sh
# Get info on the users
# Change the the vdx to suit particular user
ps -ef | grep " vdx" | grep -v grep | awk '{print $2, $5, $7}' | while read pid
time cpu
do
# Strip the ':'
cpu00=`echo $cpu | sed 's/://'`
time00=`echo $time | sed 's/://'`
time000=`echo $time00 | sed 's/://'`
currenttime=`date "+%H%M%S"`
ddate=`date`
#
# Calculate total time connected
timeon=`print $currenttime - $time000|bc`
#
# CPU usage
# 180 seconds
if [ $cpu00 -gt 180 ]
then
echo $ddate
echo EXCESSIVE CPU USER ON : $pid
kill $pid # Gracefull kill
sleep 5
kill -9 $pid
fi
done
-------------------cut-----------------
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 10:18 AM
тАО05-01-2002 10:18 AM
Re: auto kill of runaway processes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 11:39 AM
тАО05-01-2002 11:39 AM
Re: auto kill of runaway processes
Paula and Charles... thanks for the script .. will have a look. should help us.
Richard .. can't kill all processes running SAS .. they'd kill me here. Need to identify individual PIDs that are defunct but still consuming CPU and time. They look and act like a valid production job except they never end... and come up as defunct.
Jeffrey .. SAS is gonna drive me nuts some day.. had them involved.. no response yet. Will use your info to ride them a little harder.
This is a GREAT site. Thanks to all ... will let you know more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 11:44 AM
тАО05-01-2002 11:44 AM
Re: auto kill of runaway processes
Welcome to the forum.
We're all here to help each other.
Contribute as much as you can - in both directions.
And don't forget to award points to those who help you - as those whom you help will award you.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 07:45 PM
тАО05-01-2002 07:45 PM
Re: auto kill of runaway processes
What we did is that we wrote a cronjob to grep those processes and check their PPID. The stray processes have PPID set to 1. We then kill these processes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2002 11:26 PM
тАО05-01-2002 11:26 PM
Re: auto kill of runaway processes
just to share my experience.
Oracle 8i (8.1.7) has "Dead Connection Detection" (DCD). It seems like that it solves many of the lost connection problems that can occur.
Regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 12:01 AM
тАО05-03-2002 12:01 AM
Re: auto kill of runaway processes
As others have mentioned, you should post an example ps(1) output and indicate which processes you want to identify/kill.
You use the word "defunct", but not with its normal/defined meaning:
A (*real*) *defunct* process *can not* "consume CPU", so you must be refering to some other kind of process.
For a description of what defunct (zombie) processes are, see "zombie process" in the glossary(9) manual page "man glossary").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 03:23 AM
тАО05-03-2002 03:23 AM
Re: auto kill of runaway processes
That??s mean that it is NOT necesary to reboot the machine to kill the defunt process.
There is not any other way to kill a defunt process.
Try it and tell me your experience.
I hope this help you.
Juanma.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 03:39 AM
тАО05-03-2002 03:39 AM
Re: auto kill of runaway processes
first you have to check out, if any of your SAS parent processes need a signal of users child processes when they are ended. (signal SIGCHLD) If not, you could start the parent processes using the trap- command to avoid these signals send by the child- processes.
--> trap "" SIGCHLD
this commad has the effect, that no signal SIGCHLD sent by child- processes will ever reach the parent process. Normally child processes stay something like "zombies" for some milliseconds, till this signal reaches their parent process. When this signal is trapped, they change their behaviour and die immediatly.
kill -l --> output are all defined signals with names and numbers
man trap --> how to handle trap- command
Perhaps you could check out with some SAS- guys, if this is ok for SAS.
Hope this helps you!
allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 11:48 AM
тАО05-10-2002 11:48 AM
Re: auto kill of runaway processes
took some of your ideas and one of the guys here ran with.... tested and it works. In place now and kills runaway SAS processes that are flagged as 'defunct' after they've been there for 15 minutes. At first we only checked on "defunct" and found out quickly that cron was killed. Oh...OH.
Cron submits on the half hour and sends msg to log when SAS "defunct" process is found... checks 15 min. later - if still there, it's killed and msg sent to a log.
we may still have the occasional runaway with elm or xterm but we may add those conditions later. Already.. it's made my life a lot easier.
Thanks to all for your ideas and suggestions - have attached the script below.
Cheers.
Colin.
-------------------------------------
#!/bin/ksh
LOG="/var/adm/syslog/defunct_kill.log"
LogMsg () {
echo "$1"
echo "`date` --- $1" >> $LOG
}
find_defunct () {
AllPIDS=`ps -eaf | grep -i defunct | grep -v grep | awk '{print $3}'`
UniqueParentPIDS=""
for PID in $AllPIDS; do
if [[ $UniqueParentPIDS = +(*$PID*) ]];then
# We've already recorded this PID (many defunct could have same parent)
continue
fi
UniqueParentPIDS="$UniqueParentPIDS $PID"
done
SasPIDs=""
for PID in $UniqueParentPIDS; do
ParentOwner=`ps -eaf | grep $PID | grep sas | grep -v grep | awk '{print $1}'`
# We don't kill anything owned by root
# We don't keep anything that has no Owner (PID wasn't SAS or was shut down)
if [[ "$ParentOwner" = "root" || "$ParentOwner" = "" ]];then
continue
fi
SasPIDS="$SasPIDS $PID"
done
echo $SasPIDS
}
kill_defunct () {
OriginalDefunctSasPIDS=`find_defunct`
if [ "$OriginalDefunctSasPIDS" = "" ]; then
LogMsg "No Defunct Processes"
exit
fi
LogMsg "Found the following parents with defunct children: $OriginalDefunctSasPIDS"
sleep 900
CurrentDefunctSasPIDS=`find_defunct`
LogMsg "The following parents with defunct children are present after 15 minutes: $CurrentDefunctSasPIDS"
for PID in $OriginalDefunctSasPIDS; do
if [[ $CurrentDefunctSasPIDS = !(*$PID*) ]];then
LogMsg "$PID is no longer defunct or has been killed"
continue
fi
LogMsg "Killing $PID"
kill $PID
sleep 5
kill -9 $PID
done
}
kill_defunct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 12:12 PM
тАО05-10-2002 12:12 PM
Re: auto kill of runaway processes
You should really send a set of escalating signals to a pid in this order: 15 1 2 3 11 9.
Kill -11 is almost as sure a kill as kill -9 and does cleanup.
The best procedure would be to send a kill signal ${pid} then sleep a few seconds and send a kill -0 ${pid}. A zero return indicates that the process is still active so send the next signal and repeat the process. Only when all signals are used should you finally send the kill -9.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2002 06:37 AM
тАО05-11-2002 06:37 AM
Re: auto kill of runaway processes
Colin.