So I'm hosting a game that is very tempermental and can crash a lot on Linux, I made this cronjob to restart the screen and game should it fail:
#!/bin/bash
for t in {1..12} do
if [ -z "$(ps -C game | grep game)" ]
then
/usr/bin/screen -d -m -S ss13 /usr/local/bin/game /home/gamefolder/game/game.dmb 1336
fi
sleep 5
done
The cron job works just fine for starting the game server should the screen name not exist however if the game is running and crashes the cronjob fails to work and the game doesn't get restarted.
However the game is already running in the screen name ss13 and the screen itself doesn't crash, just the game. So I think what happens is that when the game crashes it tries to make a new screen with the game in but obviously can't. Is there any better method of doing this? Still quite a linux noob here.