Setting up auto-restart using screen (Unix)¶
This is a quick and ugly way of ensuring the bot is running and restarts if it is not. I’m sure there are better ways of handling this out there, but this method has worked for me for over a year already.
Note
This method uses a cronjob and screen.
How to install screen¶
$ apt-get install screen
How to access cronjob list¶
$ crontab -e
How it works¶
A bash script is created that starts the bot in a named screen.
A cronjob is created to run the bash script every minute under the same name.
- If the screen name exists, that means the bot is already running.
That’s it.