I've got python script running on a remote machine, periodically it stops responding so I ssh in, kill the existing process, and then restart it. I have to do this several times a week and it's causing long periods of downtime when I'm not around. I'd like to restart it every hour by cron - but restarting doesn't work unless I kill the process first. How would I go about killing the process by cron? Or would there be a more efficient solution.
A efficient way is changing your script where it closes all the input stream's, socket's, and such and then open's it again (like a full restart).
But your way is also good here is how you do it:
A simple way to enable killing and restarting of your process would be the
A more sophisticated method is to make a file with the process PID. For instance, it could be started like this:
Then the process can be killed like this:
You could also incorporate checks that