How to successfully kill a java process and restart it in unix? How to successfully kill a java process and restart it in unix? unix unix

How to successfully kill a java process and restart it in unix?


Instead of starting the app from the server itself, you could do a script like this:

#!/bin/shwhile [ 1 ]do    nohup java -Xmx200m -classpath bin server.Main;done

This will restart the process once it quits. And after your savestate just exit and it will restart automatically.


How about putting #!/bin/sh or something like it as the first line of your restart.bat

BTW, .bat is a very poor choice of extension on linux system.


is it safe for your JVM to be killed like that mid process? If not, you might consider a JMX bean to check the program status and do the shutdown from inside the JVM.