How can I get the PID for the current process running?

One Star

How can I get the PID for the current process running?

Hi,
How can I get the PID of the current job running?? Is there an existing global variable?
One Star

Re: How can I get the PID for the current process running?

Hi,
I have the same need : Does anyone know how it is possible to retrieve the PID of the current job ?
(The PID that we can find in the statistics and logs tables ; Fields PID, ROOT_PID...)
Thx
One Star

Re: How can I get the PID for the current process running?

You can get the job's pid by:
java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@");

ugly, but works.
One Star

Re: How can I get the PID for the current process running?

Thanks for your answer.
It seems that your code returns the system_pid.
This system_pid is present in the statistics table but not in the logs table. It's different from the field PID of these tables.
However, if there isn't a better method to retrieve this PID, i can retrieve it with the system_pid and a join between the statistics table and the logs table.
One Star

Re: How can I get the PID for the current process running?

You can get the job's pid by:
java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@");

ugly, but works.

Thanks for the info. It worked.
One Star

Re: How can I get the PID for the current process running?

hi Foldi Tamas,
Kindly explain me where I can write this and how to use this to get PID.
And also tell me where can I see the output.

Code:
java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@");

Thanks,
Satya.