List out Process ids restarted today

Hi,

I need to list out the processes which are started/restarted today in my Solaris box. If not possible need to convert the process uptime in minutes or seconds and compare it with a configurable value to list out those process ids for further processing in my scripting.

Can any one guide for that?

I have tried ps -p "123" -o etime= in the link How to check how long a process has been running? - Unix & Linux Stack Exchange where etimes is not supported in my system.

I have Solaris 10 on a Sun Blade 100 and it works for me. So what version of Solaris are you using, and which version of ps are you using? It won't work if you have /usr/ucb ahead of /usr/bin or /bin in your PATH environment variable.

Andrew

In path variable /usr/bin:/usr/ucb:/etc is available and I am using sun OS 5.10

Could you try again and post the output here if it still doesn't work? explicitly use /usr/bin/ps and ensure you are typing etime correctly.

Andrew

Same results... etime is working and not etimes

---------- Post updated at 11:22 AM ---------- Previous update was at 09:17 AM ----------

bash-3.00$ ps -p "25936" -o etime=
 8-12:14:11
bash-3.00$ 
bash-3.00$ 
bash-3.00$ 
bash-3.00$ ps -p "25936" -o etimes=
ps: unknown output format: -o etimes
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
bash-3.00$ 
bash-3.00$ 
bash-3.00$ /usr/bin/ps -p "25936" -o etimes=
ps: unknown output format: -o etimes
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
bash-3.00$ 

How about

ps -p "25936" -o etime= | awk -F"[-:]" '{print (NF==4?$1*86400:0)+(NF>2?$2*3600:0)+$(NF-1)*60+$NF}'
735251
2 Likes

Okay, I misunderstood. So etimes is different to etime. I thought you were making a typo there.

I would say at this point your best bet would be to pipe it into an awk (or perl ) one-liner which is able to identify the format being output and convert into seconds.

Andrew

With a minor change in hour field, i got the expected result. Thank you so much.

ps -p "25936" -o etime= | awk -F"[-:]" '{print (NF==4?$1*86400:0)+(NF>2?$(NF-2)*3600:0)+$(NF-1)*60+$NF}'
735251