I’ve been trying to run my java program overnight but I need to restart it sometimes to save it’s progress and completely reboot the machine. After a few hours I have the program save its progress and execute a little restart file to restart the program.
void restartServer() {
try {
Runtime rt = Runtime.getRuntime();
rt.exec("./restart.bat");
} catch (java.io.IOException err) {
logError(err.getMessage());
}
}
Inside restart.bat I have:
echo Restarting Server
killall -9 java
sleep 2;
nohup java -Xmx200m -classpath bin server.Main;
However it doesn’t work. It says:
[root@linode java]# ./restart.bat
Restarting Server
: no process killed
: command not found 3:
nohup: appending output to `nohup.out'
: command not found 4:
[root@linode java]#
Why does it say no process killed when there is a java process running? And why does it say command not found? It never restarts the program either.
How about putting
#!/bin/shor something like it as the first line of yourrestart.batBTW,
.batis a very poor choice of extension on linux system.