Search code examples
windowssolrbatch-filejettytaskkill

Gracefully kill a java (jetty/solr) process started from a windows batch file with "start /b"


I'm starting a Java background process (Solr) from a batch file with

start /b java -jar ...

The problem is that start /b will shield the process from SIGINT signals, see help start. This means that taskkill /pid ... won't work and taskkill /f /pid ... will kill the process without letting it execute shutdown hooks first.

Is there another way to start the background process on Windows from a .bat file without opening a window and without shielding it from SIGINT? Or is there another way of sending a signal to the java VM so that Solr shuts down gracefully when running from start /b?

I'd like to use a normal batch script rather than VBScript or similar if possible as this is what most our users probably know best.


Solution

  • I found a workaround for my specific case (solr + jetty), see http://alaminsumon.blogspot.com.br/2009/06/how-to-stop-and-start-jetty-server-from.html