0

I'm writing a script to start Jboss, load an application, send requests to the application, shutdown jboss and repeat. However I dont know how to shut Jboss down from the script. At the moment I'm using

pkill -9 java

But I dont think this is right, because it kills the process, not shut it down. Is there a way to shut it down similar to pressing CTRL-C?

confusified
  • 2,320
  • 7
  • 22
  • 29

3 Answers3

0

You want a simple

pkill java

From the man page:

pkill will send the specified signal (by default SIGTERM) to each process

SIGTERM will send a termination signal to the process. If the process is well-written, it will catch this signal and perform an orderly shutdown. If that fails, that's when you can use SIGKILL (-9) which is a forceable termination with no chance for the process to catch and perform cleanup.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
0

Never use kill -9 <PID> by default. It breaks things up, like file descriptors and such.

Start to run kill <PID> alone, default is -15 signal.

See

man 7 signal

And In what order should I send signals to gracefully shutdown processes?

NOTE

  • kill or pkill doesn't change things so much, same signals are trigered
Community
  • 1
  • 1
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

What you actually want is:

pkill -f jboss

using pkill java could kill any other processes using java on the box.