So basically I have one script that is keeping a server alive. It starts the server process and then starts it again after the process stops. Although sometimes the server becomes non responsive. For that I want to have another script which would ping the server and would kill the process if it wouldn't respond in 60 seconds.
The problem is that if I kill the server process the bash script also gets terminated.
The start script is just while do: sh Server.sh. It calls other shell script that has additional parameters for starting the server. The server is using java so it starts a java process. If the server hangs I use kill -9 pid because nothing else stops it. If the server doesn't hang and does the usual restart it gracefully stops and the bash script start second loop.
kill -9 pidagainst? (BTW, best practice is not to go straight to a SIGKILL, but to run a SIGTERM, wait for a while, and escalate only to KILL if the process isn't able to shut itself down in the interim).sh Server.shis not runningServer.shas a bash script, but running it as a POSIX sh script; given as this question is tagged bash, is that really what you want?)