1752374 Members
6632 Online
108787 Solutions
New Discussion юеВ

Re: check program time

 
bin lu_1
Advisor

check program time

We have over average 70+ users login using an application in production hours.

Sometimes, few of their programs "runaway" or were loop inside in Unix. then later those useless processes to the top of other running programs by different users.

Users use top to find out those runaway processes running. But our SA hope know those processes as early as we can.

I tried to time command to find them (runaway processes) in early stage. For example, find the processes stay alive 5 minutes long.

Does any one know how to get a process 5 minutes long command. I hope that I could put them in script, try to send me a email if a assigned time broken.

Thanks,

Bin
5 REPLIES 5
Simon Hargrave
Honored Contributor

Re: check program time

You can check the "elapsed" time for process on your server with something like:

UNIX95= ps -eo pid,etime,comm | grep procname

The format of the etime parameter is:

DAYS-HOURS:MINUTES:SECONDS

You can use this to check for MINUTES > 5
Simon Hargrave
Honored Contributor

Re: check program time

In fact to find all process called "procname" that have been running for 5 minutes or more: -

UNIX95= ps -eo pid,etime,comm | awk -F: '$2 >= 5 && /procname/'
bin lu_1
Advisor

Re: check program time

It works very well in Linux. I am using HP-UX, I was trying to find the same command in HP-UX

`ps -eo pid,etime,comm` does not work in HP-UX, yet.

Thank you



bin lu_1
Advisor

Re: check program time

OK, I checked more. actually the whole command you gave work on HP-UX,

Below part work for Linux
ps -eo pid,etime,comm | awk -F: '$2 >= 5 && /bonobo-activati/'

Thank yopu very much
bin lu_1
Advisor

Re: check program time

Thank you this forum platform is good