How to get process start date and time in SOLARIS?


 
Thread Tools Search this Thread
Operating Systems Solaris How to get process start date and time in SOLARIS?
# 1  
Old 02-19-2009
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
# 2  
Old 02-20-2009
What does prstat get?
# 3  
Old 02-22-2009
Just playing around, this seems to work:
Code:
# 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
#

# 4  
Old 02-22-2009
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
# 5  
Old 02-23-2009
Quote:
Originally Posted by choogendyk
That perl snippet only helps if incorporated at the time something starts.
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.
# 6  
Old 02-23-2009
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. ;-)
# 7  
Old 02-24-2009
Here is an alternative solution if you have stat installed:

Code:
stat -c %y /proc/$pid

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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

2. UNIX for Dummies Questions & Answers

how to get start time of a running process

I am trying to see if a process is running what was its start time. here is the code that I am using if then echo 'Gateway output processing started.' else VAR=$(ps -ef | grep batch_output_x ) ... fi now the problem i see is when the process is running i get two... (3 Replies)
Discussion started by: akabir77
3 Replies

3. Shell Programming and Scripting

Solaris+Perl script to get process start date

Hi all, after reading the post: * https://www.unix.com/solaris/101653-how-get-process-start-date-time-solaris.html I wrote my perl script and it worked like a charm. This script is called every 5 minutes by the monitoring server crontab and is executed on the remote network elements via ssh (the... (6 Replies)
Discussion started by: Evan
6 Replies

4. Linux

Process start time not showing correct time

Process start time is not showing the correct time: I had started a process on Jun 17th at 23:30:00. Next day morning when I run the command "ps -ef | grep mq", the process is showing the start date of Jun 17th but the start time is 00:16:41 Day/Date is setup correctly on the server. It... (2 Replies)
Discussion started by: hemangjani
2 Replies

5. HP-UX

HP UX start process at boot time

When I get start program at boot I read which run level /sbin/rcx.d runlevel=0.....x only read directory which directory name has UpperCase 'S' is not enough someone says that I need to reference another file which file I need to reference 1)/etc/rc.config.d/all file which parameter... (4 Replies)
Discussion started by: alert0919
4 Replies

6. UNIX for Dummies Questions & Answers

start process at assidned date and time

How can I start FTP at assigned DATE and TIME? (6 Replies)
Discussion started by: gd2003
6 Replies

7. UNIX for Advanced & Expert Users

start time of a terminated process

Hi, I have a shell script which i am running. I want it's starting time (the time when the execution of the shell script started) in another shell script. Note that the process has already terminated when i need it's starting time.... else i could have used ps -f | cut -d" " -f5... But that's... (2 Replies)
Discussion started by: k_chaaya
2 Replies

8. UNIX for Advanced & Expert Users

to get process start date and time

what is command to get same using ps with switch. I know process id, by specify process id. It should work on solaris and hp-ux I will be happy if for both different commands. (2 Replies)
Discussion started by: naeem ahmad
2 Replies

9. Programming

get process start time

Hi all, I like to know how can I get currenlty running process start time and date , I know only porcess id in solaris and hp-ux and what is command to get same using ps with switch. Thanks Naeem (1 Reply)
Discussion started by: naeem ahmad
1 Replies

10. UNIX for Advanced & Expert Users

start a process at boot up time

Hi, I have a program that check the IP address and automatic update it to the DNS server. I would like to run this program when the computer bootup after pppd get a connection. How do I add it to the init file. Does any one have any information of how to do it. I run a Linux Mandrake as a... (1 Reply)
Discussion started by: vtran4270
1 Replies
Login or Register to Ask a Question