3

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.

4

3 に答える 3

1

Not sure how to do it in a .bat file, but with Powershell you can do this:

Start-Process java -ArgumentList "-jar start.jar <args>" -WindowStyle Hidden

Then you can stop the process normally.

Run get-help Start-Process -detailed for more info on options - you can also easily run the process as a different user and other things that the old start won't let you do.

于 2012-11-30T17:09:30.463 に答える
0

Have you tested that? I ran:

START /B notepad.exe

and then closed it using

TASKKILL /PID 123456
于 2012-11-29T18:40:17.433 に答える
0

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

于 2012-12-01T15:33:18.260 に答える