View previous topic :: View next topic |
Author |
Message |
toralf Developer
Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Sun Aug 15, 2010 10:16 am Post subject: [solved] how do I get the start time from /proc/<pid> |
|
|
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 |
|
|
lxg Veteran
Joined: 12 Nov 2005 Posts: 1019 Location: Aachen, Germany
|
Posted: Sun Aug 15, 2010 11:35 am Post subject: |
|
|
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 |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Sun Aug 15, 2010 12:11 pm Post subject: |
|
|
Great - thx |
|
Back to top |
|
|
|