1

I have a shell script starting two java processes. How to ensure that when shell script process is killed, all It's children will be killed too? For example when I try to kill It, java processes remain alive:

kill -9 myscriptID
1
  • I hope myscript refers to its process-id here. Commented Jun 16, 2012 at 5:47

2 Answers 2

1

You can check for all java processes by running this:

ps -aux | grep *java*

This looks like it can help as well.

Sign up to request clarification or add additional context in comments.

Comments

0

Your kill command only kills your script, not other processes that it has spawned. Best way to kill all child processes has some great answers for killing the whole tree.

That said, it seems that a better design would be to keep track of the PIDs of the child processes, and rather than sending the parent SIGKILL, send it SIGTERM (or have some other way) to trigger it to gracefully kill its children.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.