Get the total amount of time a process is active
Hi
I want to get the total amount of time that a process is active or the timestamp that it was created/started.
I tried the %SYS.ProcessQuery class, but I did not find any related information.
Is there any way to get this information from a process?
I'm using Caché 2017.
Did you check GetCPUTime() method of that class?
I tried this method. But it seems that it returns from the current process, not from the referenced process.
Thanks Eduard
You can use $zu function directly with third parameter
$ZU(171,1) returns CPU time (in milliseconds) on any OS, as a string in format SYS_time,USER_time
$ZU(171,1,pid) returns total CPU time (system + user) for process pid.
However this will return CPU time -- the time CPU was actually serving the process, not the time since process was started (when process is idle, this counter does not increase). Eduard's solution would be better if you need the total time.
Nice! I was looking for something like that.
This info does not seem to be available by default.
You can define JOB^%ZSTART that would set global:
And JOB^%ZSTOP:
And reference this global to get process start time.