I have a python script running on a remote server which I start using nohup python myscript.py &
. I want to restart the script if it stops. I checked this answer but I am not sure if this starts the script. I believe it checks if the script is stopped and starts it if the script is stopped. Also, it requires the pid
of the script which would be different every time I restart the script.
I also checked this answer but I'm not sure if the nohup
command can be given the until.. do
loop. Also wouldn't it just restart my script after every 1 second? Can anyone specify how do I write a script to restart the script in case it stops?