rainman_s
rainman_s

Reputation: 1108

How to automatically kill orphaned Java processes

I've posted this question before, but didn't get the answer I wanted. The problem I have right now is that there are a number of Java processes getting orphaned. This is both on Linux and Windows. I need a way to FIND which Java processes are the ones that are orphaned and kill them.

NOTE: I CANNOT make changes to the Java code as I have no access to it on any level. I am simply running some tests on my machine. I am aware of solutions like this one Killing a process using Java but that is not what I am looking for.

Upvotes: 0

Views: 2112

Answers (1)

Joni
Joni

Reputation: 111409

On Linux an orphaned process becomes the child of init, which always has pid 1. To kill java processes that are children of init you can use pkill:

pkill --parent 1 java

To make this automatic you can add this command to cron, for example.

Upvotes: 3

Related Questions