Within a process is there an API I can use to programatically determine the wall-clock time since the process started, on Linux?
Asked
Active
Viewed 118 times
0
-
duplicate https://stackoverflow.com/a/13780824 – user1462442 Mar 03 '19 at 16:00
-
man time: https://linux.die.net/man/1/time – Alejandro Blasco Mar 03 '19 at 16:17
-
@AlejandroBlasco - sorry, but it wasn't clear, but I'm looking for an API to use _within_ a running process to determine the time it has been running. – BeeOnRope Mar 03 '19 at 16:44
-
@user1462442 - if it's a duplicate, it isn't obvious (to me anyways). Where can the answer be found there? I see mostly mentions of a few Linux utilities that report things like CPU time. – BeeOnRope Mar 03 '19 at 16:45
-
1@BeeOnRope found this answer, hope this helps: https://stackoverflow.com/a/6553466/3589567 – Alejandro Blasco Mar 03 '19 at 16:52
-
@BeeOnRope you can subprocess call the bash utilities or read /proc file system. OS is an application library itself. – user1462442 Mar 03 '19 at 19:56
-
Which language? – jww Mar 04 '19 at 11:03
-
@jww I guess C or C++. I guess some languages might offer this as part of their runtime, e.g., take a timestamp early in the startup process and then offer the option to query this (like [this in Java](https://stackoverflow.com/a/817835/149138)), but it misses whatever happens before the timestamp is taken - unless of course they don't use the "early timestamp" approach but instead ask the OS, in which case I'd be interested to know. – BeeOnRope Mar 04 '19 at 20:55