If your server runs systemd, I would strongly recommend to use that instead of a shell script. You can use "Restart=always" or "Restart=on-failure" in the unit file. It also provides socket activation, which will allow you to restart the program without downtime.