How to Identify long running unix processes

Hi All, Need an urgent help, I have a requirement to find long running unix processes.. I have tried the below commands, but not succeed. I need to arrange the unix processess in an order of elapsed time (high to low) that runs in a system.
For Eg:
Consider we have 3 processes,
Pid 1
pid 2
pid 3
pid 1 is running for past 3 hours
pid 2 is running for past 5 hours
pid 3 is running for past 1 hour
The output of the command should be like this..
Descending order based on how long it runs...
pid 2 (5 hours)
pid 1 (3 hours)
pid 3 (1 hour)

Tried what commands?

Thanks for the quick response... BTW we are using AIX UNIX - Version 6.1.0.0.

  1. Top is not supporting..
$ top -d 1 -o time | awk 'NR > 7 && int($9) > 12'
ksh: top:  not found.
  1. This command is arranging the processes only minutes level and hours are not coming in the top..
ps -A -o user,pid,etime,args | grep normetl | awk '{print $1":"$2":"$3"-"$4"-"$5"-"$6"-"$7}' | sort -r -t: +2 | head
ps -ef|grep normetl|cut -c1-15,42-79|sort -rn +2
ps -ef | sort -n -k 5,5

None of the above is helpful..

Thanks in advance..
Irfan.

Couldn't you run the output through tr -d ':-' , so you can sort -rn on the column of etime ?

Please post sample (abridged and relevant) output from options 2) 3) and 4).

Too true.

Please post man ps from your system (or prefarably a link to an online manual) and sample lines from ps -ef for representative processes and define in words (not code) what constitutes a "long running unix process". For example processes such as "syslogd" will keep running from the moment the system boots.

Because the ps command has so much variation, please post some base facts:
Operating System and version uname-a (blot anything confidential with X's). Shell: echo $SHELL .

Hi methyl,

Thanks for your response, I am using AIX server unix K shell. following are the things you asked.

Unix Man page :

ps -ef command:

0413021901 ReadyJob.GetJobDetails 1 0/0/1 
etlusr 5113116 1 0 03:15:45 - 0:00 /home/db2clip/sqllib/bin/db2bp 21235292A55544 5 A 
etlusr 16385286 47187580 0 02:19:08 - 0:02 phantom DSD.StageRun TrnSchedulerMaxRun.20120413021902 MaxRun.TraGetInvID 1 0/0/1 
etlusr 36046106 16385286 0 02:19:11 - 0:00 phantom DSD.RUN ReadyJob.20120413021902 0/0/1/0/0 

$ uname -a

AIX TESTSERV 1 6 00F625964C00