06-17-2006, 12:42 PM
hello,
i found somewhere on the internet ( had to do a lot of moves to get this file from a site which is not online anymore.. thanks google )a nice script for linux servers which can automatically reboot your cs source server for example during the night.
why need a reboot script ? well from what i have noticed myself, is that the memory for instance is eaten and increases. had my cs source server running for 4 weeks without restarting, which ended up of 67 % of the memory been used by the source engine.
For 1 server it is not such a problem but if you have a lot of game servers running then it would be nice that an automatic process can kick your servers offline and bring it back in order to reset the memory usuage.
So you have a clean fresh server everyday.
This script was written by : Ole Christian
What do you need for this script :
- screen function ( google on your linux version and screen )
- crontab -e
This is the code :
The installation is actually really simple :
- Download the file from the attached file on this post.
- Or do this in your console : wget http://www.cs-source.nl/files/srcds.sh
- place the file srcds.sh in the same folder as where your srcds_run is placed
- do a : chmod 777 srcds.sh in console
- edit the srcds.sh
Most important changes are :
- SRCDS_PATH
- SRCDS_OPTS
Make sure you fill in the full path to the srcds.sh file.
For example : SRCDS_PATH="/home/peter/srcds/
If you do not do this then the script will not restart your server.
One comment on editing the file srcds.sh, make sure you do this in an editor which is capable of linux enviroment. If you edit it on your notepad in windows and put it back, you will get some funky errors about missing parameters...
Use nano or vi editor.
Oke now you need to edit the crontab option
- use command : crontab -e
fill in the following command for example :
* 8 * * * /path/to/srcds.sh restart >/dev/null 2>&1
This cronjob will give a command to srcds.sh to restart on 8 o clock.
( check google for more info about cronjobs )
This command '>/dev/null 2>&1' makes sure the restart msg will not be mailed.
Start the script using in the folder of where it standing with :
- ./srcds.sh start
It will now start the server in the background using screen.
Check with screen -r if the server is starting.
That's it actually.
Looks hard but it's quite simple.
Been using it for a couple of days now and it really works well.
i found somewhere on the internet ( had to do a lot of moves to get this file from a site which is not online anymore.. thanks google )a nice script for linux servers which can automatically reboot your cs source server for example during the night.
why need a reboot script ? well from what i have noticed myself, is that the memory for instance is eaten and increases. had my cs source server running for 4 weeks without restarting, which ended up of 67 % of the memory been used by the source engine.
For 1 server it is not such a problem but if you have a lot of game servers running then it would be nice that an automatic process can kick your servers offline and bring it back in order to reset the memory usuage.
So you have a clean fresh server everyday.
This script was written by : Ole Christian
What do you need for this script :
- screen function ( google on your linux version and screen )
- crontab -e
This is the code :
Code:
#!/bin/sh
#############################################
## SRCDS SERVER STARTUP SCRIPT V1.0 ##
## [10.10.2005] ##
## Created by: ##
## Ole Christian Rynning <oc@rynning.no> ##
## jce #norge.css @ quakenet ##
#############################################
#############################################
## CUSTOMIZE THESE VARIABLES TO YOUR NEEDS ##
#############################################
###
# SCRDS_NAME is the name of the instance
# for example customer_css, clanwarserver,
# and so on.
# Default: css
SRCDS_NAME="css"
###
# SCRDS_BIN is the binary used to run the
# server, for srcds linux, it is commonly
# ''srcds_run''
#
# The reason it is prefixed by ./ is that
# the script by default changes dir to the
# SRCDS_PATH directory before running the
# binary
SRCDS_BIN="./srcds_run"
###
# SRCDS_PATH defines the physical location
# where srcds is installed;
# for instance:
# ''/home/customer/srcds/''
SRCDS_PATH="."
###
# SRCDS_PIDFILE lets you specify a pidfile.
# if you want the pidfile in another location
# than the base dir of $SRCDS_PATH, you need
# to specify the full path;
# for instance:
# ''/home/customer/tmp/warserver.pid''
SRCDS_PIDFILE="${SRCDS_NAME}.pid"
###
# SRCDS_OPTS is all the default start options
# for the server that you cannot set in the
# server config files. Options such as tickrate,
# ip, port and max_fps are set here
SRCDS_OPTS="-game cstrike -console \
-autoupdate -pidfile ${SRDCS_PIDFILE} \
-tickrate 100 +maxplayers 12 +map de_dust2 \
-ip 217.78.96.31 -port 27015 +fps_max 600"
#############################################
## DO NOT EDIT ANYTHING BELOW THIS LINE! ##
#############################################
usage() {
echo "Usage: ${SRCDS_NAME} (stop|start|restart)"
exit 2
}
if [ -z $1 ]; then
usage
fi
srcds_start() {
OWD=`pwd`
cd $SRCDS_PATH
screen -AmdS ${SRCDS_NAME} ${SRCDS_BIN} ${SRCDS_OPTS}
cd $OWD
}
srcds_stop() {
screen -dr ${SRCDS_NAME} -X quit
}
srcds_restart() {
srcds_stop
srcds_start
}
case $1 in
stop)
srcds_stop
;;
start)
srcds_start
;;
restart)
srcds_restart
;;
*)
usage
esac
exit 0
The installation is actually really simple :
- Download the file from the attached file on this post.
- Or do this in your console : wget http://www.cs-source.nl/files/srcds.sh
- place the file srcds.sh in the same folder as where your srcds_run is placed
- do a : chmod 777 srcds.sh in console
- edit the srcds.sh
Most important changes are :
- SRCDS_PATH
- SRCDS_OPTS
Make sure you fill in the full path to the srcds.sh file.
For example : SRCDS_PATH="/home/peter/srcds/
If you do not do this then the script will not restart your server.
One comment on editing the file srcds.sh, make sure you do this in an editor which is capable of linux enviroment. If you edit it on your notepad in windows and put it back, you will get some funky errors about missing parameters...
Use nano or vi editor.
Oke now you need to edit the crontab option
- use command : crontab -e
fill in the following command for example :
* 8 * * * /path/to/srcds.sh restart >/dev/null 2>&1
This cronjob will give a command to srcds.sh to restart on 8 o clock.
( check google for more info about cronjobs )
This command '>/dev/null 2>&1' makes sure the restart msg will not be mailed.
Start the script using in the folder of where it standing with :
- ./srcds.sh start
It will now start the server in the background using screen.
Check with screen -r if the server is starting.
That's it actually.
Looks hard but it's quite simple.
Been using it for a couple of days now and it really works well.