SRCDS Steam group

start server on reboot -- linux only
This tutorial is for linux servers as I do not run win32 servers.

To start off this tutorial you'll need to add
to your srcds_run command. this will add the process id into a file. At the moment of writing this, -pidfile did not work correctly so until valve fixes this, you can use this. which is a patch for srcds_run to use -pidfile
on to the next part, you'll need a crontab, i happen to use vixie-cron. most distros probably come with cron however. If not you can try this, for fedora and debian you can probably..
Quote:Fedora: yum vixie-cron
Debian apt-get vixie-cron
FreeBSD: use ports to install vixie-cron(if you don't know how to do this, you shouldn't be using FreeBSD Smile)
Gentoo: emerge vixie-cron

When crontab is installed simply run "crontab -e" to open the cron editor and add:
*/5 * * * * /home/yoursrcdspath/

This will make cron run every 5 minutes. be sure you change "yoursrcdspath" to the path of your srcds_run. You can change the /5 to /1 if you wish. Credit: SirTiger from his full throttle tutorial.

next we'll need the

# change this to how you normally run your srcds:
srcdexe="srcds_run -game cstrike -ip -port 27015 +map de_dust +maxplayers 20 -pidfile"

# I wouldn't touch this if I were you.

########## you probably don't need to change anything below here ##########

cd $dir
if test -r $srcdname; then
  # there is a pid file -- is it current?
  srcdpid=`cat $srcdname`
  if `kill -CHLD $srcdpid >/dev/null 2>&1`; then
    # it's still going
    # back out quietly
    exit 0
  echo "Source Dedicated Server Crontab notice:"
  echo ""
  echo "Stale $srcdname file (erasing it)"
  rm -f $srcdname
echo ""
echo "Couldn't find the srcds running.  Reloading it..."
echo ""
don't forget to
chmod +x
This will also help if the server stops for some reason and does not auto start. There is another way of doing this, which is adding to rc scripts. for gentoo its in
I'm not sure about fedora or debian , its probably something like
if someone would please clearify this i'll edit the tutorial to fit it.

Please note that your user that runs this script in cron tab, must be in the group cron.
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
Debian users should use a symlinked script (using update-rc.d preferably) found in /etc/rcX.d (where X is the runlevel you're after, 2 upwards is multiuser). You can (if you're confident) place your script in /etc/init.d/ and then add a symlink to the appropriate rc directory in the following format:
SXXname -> ../init.d/scriptname*
First letter of the ln name should be S or H (start or halt), the XX is a number between 01 and 99 to indicate the order this program should be run, and the name is chosen by you (should reflect the name of the script/program to run).

Alternatively, if you're of a nervous disposition I would suggest the following modifications if you're running Debian:

Place the into /etc/init.d/ and then use the following command (from any directory).

update-rc.d defaults 99

This will add your script to all the important (non halt, non reboot) runlevels and give it a start priority of 99 (basically it will be the last thing to startup - change this if you like).

Hope this helps,

For Fedora and other Red Hat flavors, services are started by SysV initscripts in /etc/rc.d/*. There's an init.d subdirectory where the actual script is stored. There are also per-runlevel subdirectories rc0.d through rc6.d that hold symlinks to the actual scripts. These symlinks are created and managed by the chkconfig command.

For more information, look in /usr/share/doc/initscripts-*. (The directory name will end in the version of the initscripts package you have installed.)

I haven't yet written one of these for srcds but I've written them for Tribes 2, Tribes Vengeance, and BF1942. You can see my TV scripts here:
Hey, I've been trying to use the crontab method of starting the server. The problem I'm running into is that the script won't execute via crontab. After I fixed the typo on one of the variable names, it works fine when I run it directly, but when I put it into cron for the user who should be running the server nothing happens. Does anyone have any ideas?
Try adding that user to the cron group
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
cryotek Wrote:Try adding that user to the cron group

Yeah, I did that, and cron is running, but the server still isn't being launched.
is there a dead.letter in the users homedir?
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
I've put the init-script for SuSE and the UnitedLinux-flavors on my webserver. It uses a configfile in /etc/sysconfig where all the settings can be made (such as map, maxplayers etc).
When you use SuSE you can also use Yast to modify the settings.
In the archive is a readme how to use it.

Download it
Note for our MickeySoft users:
A reboot a day, keeps Dr.Watson away Big Grin
Doh! I just noticed my response never got posted. How annoying. I got it working. It seems EL3's cron for some reason doesn't support the */5 style, so I replaced it with 0,5,10,15... and it works fine.
ok problems.. i have started a new crontab and got the pidfile, and everything but the server will not work. i manually got into shell and used the suplied .sh file and manually ran the program and it worked.

do i need to have a shell running in order for crontab to work? if not why isnt it running.. i tried it under the user and also root with no success.
What distro? Is some kind of cron service installed and running?
yea i edited the cron and everything also when that didnt work i have plesk reloaded on my machine and added a new crontab in there as well. tried it as root, didnt work.

fedora core 2 is my distro..

thanks for the responce.
Does anyone have a mirror for the pid patch? It's 404ing.
ya i need that patch too...
nmd, they fixed it no need for patch
if you want da patch anyway there is a link

Forum Jump:

Users browsing this thread: 1 Guest(s)