Operating System - HP-UX
1748081 Members
5284 Online
108758 Solutions
New Discussion юеВ

Re: How to find the process started date with year

 
SOLVED
Go to solution
senthil_kumar_1
Super Advisor

How to find the process started date with year

Hi All,

I am not able to see the started the date (with date and year) of the process using the command "ps -ef | more".

For example:

#ps -ef | more
UID PID PPID C STIME TTY TIME COMMAND
root 0 0 0 Nov 12 ? 3:34 swapper
root 1 0 0 Nov 12 ? 19:36 init
root 2 0 0 Nov 12 ? 1954:12 vhand
root 3 0 1 Nov 12 ? 1585:25 statdaemon


In above command, it is showing only month and date under STIME (start time) but not year.

I want to view the date with year.

Is it possible?

How to see that?
15 REPLIES 15
Jeeshan
Honored Contributor

Re: How to find the process started date with year

STIME is the process start time
a warrior never quits
Pete Randall
Outstanding Contributor

Re: How to find the process started date with year

A little logic might help. If you run the "uptime" command and do a little math, you can figure this out. My first guess would be 2009, but if uptime indicates you've been up longer than 450 or so days, it must be 2008.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: How to find the process started date with year

Hi Senthil:

> In above command, it is showing only month and date under STIME (start time) but not year. I want to view the date with year.

The manpages suggest that you will have to filter the output to reformat things. I'm not sure why you want the year displayed.

You might map the month name to its ordinal value. Compare that value to the current month ordinal. If the first value is greater than the current month, then the year is year-1. In your example, Nov(ember) [11] is greater than Apr(il) [4], so we might assume that the process started in 2010-1 or 2009.

Again, why do you care?

Regards!

...JRF...
Robert Salter
Respected Contributor

Re: How to find the process started date with year

The processes you list are usually started at boot up. Check the /etc/shutdownlog or /etc/rc.log files, they'll show you the year. Maybe there's a pid file in /var/run or somewhere that an app would put it.

If it's an app process that has a mmmdd for STIME, based on the last time the server was booted you could get a good idea of the year when the app process started.

Other than that the man page for ps states that after 24 hours,the starting date for a process is displayed, obviously without the year.

beers,

robert
Time to smoke and joke
Raj D.
Honored Contributor

Re: How to find the process started date with year

Senthil,

These are primary process and starts during system startup,
root 0 0 0 Nov 12 ? 3:34 swapper
root 1 0 0 Nov 12 ? 19:36 init
root 2 0 0 Nov 12 ? 1954:12 vhand

Use uptime to determine the process start time, [ Current date - server uptime date ]
# uptime


You can try:
# UNIX95=1 ps -e -o pid,ppid,time,etime,args | more

etime will show the : Elapsed time of the processes. under the field ELAPSED.


Hth,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Dennis Handly
Acclaimed Contributor
Solution

Re: How to find the process started date with year

>I want to view the date with year.

This thread wanted to know the start time in minutes and seconds. I assume adding the year is trivial.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1395780
Suraj K Sankari
Honored Contributor

Re: How to find the process started date with year

Hi,
>>want to view the date with year.
I dont think so we can see the year

>>Is it possible?
yes for time its possible

>>How to see that?
I am using this below command
UNIX95= ps -e -o time,etime,pid,ppid,args

Suraj
S-M-S
Valued Contributor

Re: How to find the process started date with year

Hi Senthil,

Better you compare the ps -ef out put and the uptime (TIME )in "top" utility for same PID
DeafFrog
Valued Contributor

Re: How to find the process started date with year

Hello to All ,

Raj : "etime will show the : Elapsed time of the processes. under the field ELAPSED"

for many process it shows as "122-04:20:13" , how to comprehend that ?

Regards ,
FrogIsDeaf