04-09-2005, 10:37 PM
This is an utterly simple script to keep your server going. This can be expanded to do so much more, though that is for another day. I am posting this as mainly a starter script for some of you guys out there. (not many people ever use tldp.org, so ill bring it to you)
Create srcds_up.sh
Now create a cronjob by typing "crontab -e"
That cronjob runs srcds_up.sh every minute. Your server should stay running unless it hangs and becomes a zombie process or you add a mod that causes it to crash over and over again.
*Hint if you want to add in some error checking to see if the server is up and accepting connections not just running, use qstat. -=]
Create srcds_up.sh
Code:
#!/bin/sh
css="/home/myhomedir/css/"
process=`ps uxw | grep srcds_run | grep -v grep | awk '{print $11}'`
if [ -z "$process" ]; then
echo "Couldn't find CSS running, restarting it."
cd "$css"
screen -d -m ./srcds_run -game cstrike -pingboost 3 -port 27015 +ip 127.0.0.1 +maxplayers 18 +map de_dust -autoupdate
echo "Server Started"
fi
Now create a cronjob by typing "crontab -e"
Code:
*/1 * * * * /home/myhomedir/srcds_up.sh
That cronjob runs srcds_up.sh every minute. Your server should stay running unless it hangs and becomes a zombie process or you add a mod that causes it to crash over and over again.
*Hint if you want to add in some error checking to see if the server is up and accepting connections not just running, use qstat. -=]