Process running time by taking user input

Need help in scripting . Below is the situation and need your inputs

Checking all the processes, scripts running time based on user input time . Below Example

ps -aef -o user,pid,etime,stime,args| grep sleep
  <user> 28995       01:24 14:14:39 sleep 120
  <user> 29385       00:52 14:15:10 sleep 1000
  <user> 29415       00:48 14:15:14 sleep 2000
#./process_check.sh  20   # scriptname minutes 
<user> 28995       20:24 14:34:39 sleep 120

(display all process,script running 20 minutes

Thank you for your help

Do you mean the user sets the criteria for filtering by run time? Sounds like a good perl DateTime::Format::Strptime - search.cpan.org or awk Time Functions (The GNU Awk User’s Guide) thing, where you can parse the time to filter. As I am a ksh guy not on LINUX usually, I wrote a C command tm2tm that does all sorts of time input strptime(3) - Linux man page, delta and output strftime(3): format date/time - Linux man page available here: "date" difference between FreeBSD & Linux

Would you be able to help me in getting

List of all processes running more that 30 mintures.

We have discussed similar topic in your previous thread

Where are you stuck now?

Try this

ps -eaf -o user,pid,etime,stime,args | awk 'NR>1{n=split($3,t,/:/);if(n==3||t[1]>=30){print}} '

--ahamed

Thank you Ahamed It works . Thank you

Seems simple:

$ ps -efx | grep -v '^.\{41\} [ 1-2][0-9]:[0-5][0-9] ' | pg
     UID   PID  PPID  C    STIME TTY       TIME COMMAND
    root     3     0  3  Feb 16  ?        285:57 statdaemon
    root   486     1 10  Feb 16  ?        1386:01 /usr/sbin/syncer
    root    40     0  0  Feb 16  ?        103:51 vxfsd
    root  1861  1443  0  Feb 16  ?        80:01 diaglogd
    root   617   616  0  Feb 16  ?        38:28 /usr/sbin/netfmt -C -F -f /var/adm/nettl.LOG00 -c /var/adm/conslog.opts
    root   750     1  0  Feb 16  ?        138:56 /opt/quest/sbin/vasd -p /var/opt/quest/vas/vasd/.vasd.pid
    root  1600     1  0  Feb 16  ?        90:44 /opt/perf/bin/scopeux
 
 .
 .
 .
 .

DGPickett

Somehow i don't have the X option for my Unix server .

bash-3.00$ ps -efx | grep -v '^.\{41\} [ 1-2][0-9]:[0-5][0-9] '
ps: illegal option -- x
usage: ps [ -aAdeflcjLPyZ ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid ctid
        pri opri pcpu pmem vsz rss osz nice class time etime stime zone zoneid
        f s c lwp nlwp psr tty addr wchan fname comm args projid project pset

Yes, some use w and sometimes you need an alternate path to an xpg4 version. I have no o option, but for me it works without the x, just less command info.