Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How can I see when a process started, assuming I know the pid. (On Linux)

share|improve this question

5 Answers 5

up vote 14 down vote accepted

If you want only the start time, you can select the field and suppress the header by doing this:

 ps -p YOURPID -o lstart=

the output will look like this:

 Mon Dec 14 17:17:16 2009

which is ctime(3) format and you can parse it to split out the relevant parts.

Other start fields such as start, stime, bsdstart and start_time age the time (after 24 hours only the date is shown, for example).

You can, however, use them directly for recently started processes without further parsing:

ps -p YOURPID -o stime=

which would output something like:

09:26
share|improve this answer

"ps -f" - it's in the man pages

share|improve this answer
2  
And to select the known pid: ps -f -p yourpid –  Dennis Williamson Dec 18 '09 at 15:05

awk '{print $22}' /proc/$pid/stat - gives you the start time in jiffies after boot

share|improve this answer
    
Beautifully obscure answer! –  wzzrd Dec 18 '09 at 10:23
    
Riddle me this. A system with an uptime of '17:57' has a process with a start time of '727975'. Looks like the process started 8 days from now? –  Scott Pack Dec 18 '09 at 13:25
1  
It's actually in jiffies (100/sec) –  MarkR Dec 18 '09 at 14:32
    
Way too obscure! And besides, now you have to look up the boot time and do the math to convert jiffies to seconds and calculate the offset to get clock time. Easy, but too many steps. See Chopper3's answer. –  Dennis Williamson Dec 18 '09 at 15:08

one way you can ps -f |grep as you said you the pid other wise you can wise in top also

share|improve this answer

Or, in the case where there's a single process on each host, you can do:

ps -p `pgrep openvpn` -o lstart=
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.