Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] how do I get the start time from /proc/<pid> ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3943
Location: Hamburg

PostPosted: Sun Aug 15, 2010 10:16 am    Post subject: [solved] how do I get the start time from /proc/<pid> Reply with quote

I'm pretty sure something in /proc/<pid>/stat* is the answer[Update]This is wrong[/Update], but which value is it ?

The background is to kill a process after a given time, eg. 5 min after it started.


Last edited by toralf on Sun Aug 15, 2010 12:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Sun Aug 15, 2010 11:35 am    Post subject: Reply with quote

You could take the start time of the process (e.g. stat --printf='%Z' /proc/PID), the current system time and calculate the difference.

edit: For example:

Code:
echo $[ $(date +%s) - $(stat --printf='%Z' /proc/1) ]


edit 2: I doubt you'll find the information inside of one of the /proc/PID files: http://www.rt-embedded.com/blog/archives/process-information-in-the-proc-filesystem/
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3943
Location: Hamburg

PostPosted: Sun Aug 15, 2010 12:11 pm    Post subject: Reply with quote

Great - thx
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum