Re: Script to check for process over Xminutes old and kill?

From: Taylor, David (DTaylor@WBMI.COM)
Date: Fri Oct 17 2003 - 13:39:43 EDT


for PROC in `psef krshd`; do
   PID=`echo $PROC | awk '{print $2}'`
   integer MIN=`echo $PROC | awk '{print $8}' | cut -f2 -d:`
   if [ $MIN -gt 10 ]; then
      kill $PID
   fi
done
------------------------------

I'm assuming that you would run this more frequently than once an hour.
Otherwise you'd need to test for the hour field of the time.

BTW - what is psef?

HTH

David

-----Original Message-----
From: Clifton, Pablo [mailto:Pablo.Clifton@BCBSFL.COM]
Sent: Friday, October 17, 2003 11:03 AM
To: aix-l@Princeton.EDU
Subject: Script to check for process over Xminutes old and kill?

Hi-
does anyone already have a script that will:

        "look for specific processes running for more than X minutes
old"

I need a script that will look for "krshd" processes over 10 minutes old
and kill them.

root@hostA:/:>psef krshd
    root 24994 4644 0 Sep 26 - 0:45 krshd
    root 44660 4644 0 Sep 26 - 0:21 krshd
    root 54796 4644 0 Sep 17 - 0:52 krshd
    root 102858 4644 0 Sep 17 - 0:44 krshd
    root 103518 4644 0 Sep 26 - 0:43 krshd
    root 137114 4644 0 Sep 26 - 0:22 krshd
    root 222050 4644 0 Sep 26 - 0:45 krshd

thanks,
-pablo

Blue Cross Blue Shield of Florida, Inc., and its subsidiary and
affiliate companies are not responsible for errors or omissions in this
e-mail message. Any personal comments made in this e-mail do not reflect
the views of Blue Cross Blue Shield of Florida, Inc. The information
contained in this document may be confidential and intended solely for
the use of the individual or entity to whom it is addressed. This
document may contain material that is privileged or protected from
disclosure under applicable law. If you are not the intended recipient
or the individual responsible for delivering to the intended recipient,
please (1) be advised that any use, dissemination, forwarding, or
copying of this document IS STRICTLY PROHIBITED; and (2) notify sender
immediately by telephone and destroy the document. THANK YOU.

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:17 EDT