Check if $JOB is running?
Hello,
For many routines we write, we utilize a global we name ^HITLIST($JOB,"routineName") as temporary storage as needed. For various reasons this gets junked up and we are at a point where we need to do some routine garbage collection.
The idea is to write a utility that looks at all the ^HITLIST($JOB) nodes, check if the job is currently running and if it isn't then we can issues the KILL command on ^HITLIST($JOB).
We looked at the methods in %SYSTEM.Process and couldn't find a method that clear told us that a job was running or not. The most promising seemed to be %SYSTEM.Process.State($J) but we tried both $J and the string "TEST" and got the result "RUN", so I'm not sure we understand its use.
There's documentation for %SYS.ProcessQuery which has an example where we capture a result set using the query %SYS.ProcessQuery:ListPids. It seems to guarantee returning a result set of all processing running on the system. We can run our ^HITLIST($JOB) node against this and manage appropriately. This however is less real time than looking at the job number and calling a method to immediatily ask if it's running right now.
Does anyone have some other thoughts or reliable ways to check if a job is running?
Best,
Mike