Skip to main content

$JOB (ObjectScript)

Contains the ID of the current process.

Synopsis

$JOB
$J

Description

$JOB contains the ID number of the current process. This ID number is the host operating system’s actual Process ID (PID). This ID number is unique for each process.

The format of the string returned to $JOB is determined for the current process by the setting of the NodeNameInPid()Opens in a new tab method of the %SYSTEM.ProcessOpens in a new tab class. The system-wide default behavior can be established by setting the NodeNameInPidOpens in a new tab property of the Config.MiscellaneousOpens in a new tab class. By default, $JOB returns only the PID, but you can set these functions to have $JOB return both the PID and the node name. For example: 11284:MYCOMPUTER.

This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.

To establish the PID as the terminal prompt, use the TerminalPrompt(5)Opens in a new tab method of the %SYSTEM.ProcessOpens in a new tab class.

Other Information About the Current Process

You can obtain the same current process ID number by invoking the ProcessId()Opens in a new tab method, as follows:

   WRITE $SYSTEM.SYS.ProcessID()

Refer to the %SYSTEM.SYSOpens in a new tab class in the InterSystems Class Reference for further details.

You can use $JOB to obtain the job number for the current process as follows:

   SET JobObj=##class(%SYS.ProcessQuery).%OpenId($JOB)
   WRITE JobObj.JobNumber

Refer to the %SYS.ProcessQueryOpens in a new tab class in the InterSystems Class Reference for further details.

You can obtain status information about the current process from the $ZJOB special variable.

You can obtain the PID of the child process or the parent process of the current process from the $ZCHILD and $ZPARENT special variables.

You can obtain the PIDs of the current jobs in the job table from the ^$JOB structured system variable.

See Also

FeedbackOpens in a new tab