0

Anyone knows how I can automatically start a java server in batch file when it stops running?

I have the following batch file below but it only starts the server.

//test.bat
start java -jar myserver.jar

dimas
  • 2,487
  • 6
  • 40
  • 66
  • Well with cygwin you could run a cron job to check if it's running then start it if it's not. There might be a powershell alternative that I don't know of. – Daniel Kaplan Feb 05 '15 at 21:23
  • You need to figure out when the application is no longer running and then run your existing batch file. Look here: http://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script – MarsAtomic Feb 05 '15 at 21:23
  • @MarsAtomic thanks for answering. Ive already looked at that link however I don't know what to pass on the IMAGENAME part tried inserting the name of my jar but it doesn't work – dimas Feb 05 '15 at 21:25
  • When you run your Java server, what's its name in Task Manager? – MarsAtomic Feb 05 '15 at 21:32

1 Answers1

0

You can use everyone's favorite, goto:

:loop
java -jar myserver.jar
goto loop
Ecliptica
  • 760
  • 2
  • 8
  • 21
  • hi i used this previously but this will spawn a lot of instances of my myserver.jar 100 or more times in a second – dimas Feb 06 '15 at 11:16