I have a Python script that uses Twitter's streaming API, but it usually crashes after a day or two. I have not been able to pinpoint the cause, and after more than a month of trying, I've stopped trying to do so. Instead, I occasionally SSH into the Pi, check the list of screen sessions and start the script again if it has crashed.
Obviously, this isn't very effective, as the script sometimes stops running and hours pass until I'm able to check the Pi again, which is why I want to automate all that. I checked out Monit, which seems to be able to do what I want, but I don't know how to do it, and its ~100 man pages don't help.
So: How do I get Monit to check whether my script is running in a screen instance and restart it if it isn't? I had the idea of somehow grepping the output of screen -list and using that, because all my screen sessions have names set, but I'm not proficient enough with all that Terminal stuff to do that.