How to get process start date and time in SOLARIS?

how can I get the process start date and time?

using ps command i can get the timstamp for a process, which are started today. and only date (MMM DD) for others.

i need to get both for all the running process.

please help.

Regards,
Jagadeeswaran.K

What does prstat get?

Just playing around, this seems to work:

# pid=495
# perl -e '@d=localtime ((stat(shift))[9]); printf "%4d%02d%02d%02d%02d%02d\n", $d[5]+1900,$d[4]+1,$d[3],$d[2],$d[1],$d[0]' /proc/$pid
20090217132804
#

That perl snippet only helps if incorporated at the time something starts. If you are looking back at what is currently running on the system, then ps only gives HH:MM:SS for processes started in the last 24 hours. Processes started prior to that get month and day of the month only.

I haven't actually tried this, but there are some scripts listed on the opensolaris site that are tailored for Solaris 10 or for Solaris 9 that collect diagnostics for running processes, including stime. They might do what you want:

Live System Data Gathering at OpenSolaris.org

May I inquire as to what tests you performed to reach that conclusion?

I tested it extensively before I posted. It correctly reported the start time of any running process, including some that have been running for months.

My apologies. My view of the posting truncated the long line. Going back to look at it again, I see that it works.

Interesting that you could also do `ls -l /proc | grep $pid`, but you wouldn't get the seconds -- only the hour and minutes.

So, now the OP has 3 different solutions to choose from. :wink:

Here is an alternative solution if you have stat installed:

stat -c %y /proc/$pid

eg:

$ stat -c %y /proc/$$
2009-02-23 20:21:24.608143611 -0700

Thanks folks..... for your efforts..

really all helps me.