I am looking for a way to automatically restart my servers if they crash (VDS). Support ticket advised me to go on here to ask about how to do it with .bat files
Let's say I am running "C:\hlds" -game cstrike, and I also want it to be set at high priority on windows. How should I write a loop .bat file to achieve this?
Thanks a lot
Making .bat files to keep my servers on 24/7
-
- New to forums
- Posts: 2
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Thu Feb 28, 2013 7:57 am
Re: Making .bat files to keep my servers on 24/7
This was the .bat file I used with my Team Fortress server, it will work with CS also. You have to keep the computer logged in at all times unfortunately. I think eventually I began to use RunAsSvc instead so I didn't have to be logged in to run the server. http://www.pirmasoft.com/runassvc.php
Hope this helps!
Carl
Code: Select all
@echo off
title SRCDS Idle Watchdog/Updater
cls
echo (%date% %time%) Now starting SRCDS Watchdog/Updater
echo (%date% %time%) Now starting SRCDS Watchdog/Updater >> watchdog.log
:begin
echo (%date% %time%) Checking for SRCDS updates
echo (%date% %time%) Checking for SRCDS updates >> watchdog.log
start /wait C:\tf2\hldsupdatetool.exe -command update -game tf -dir C:\tf2\rotation
echo (%date% %time%) Starting server
echo (%date% %time%) Starting server >> watchdog.log
start /wait C:\tf2\rotation\orangebox\srcds.exe -game tf -console +maxplayers 24 -ip xx.xx.xx.xx -port 27015
echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting
echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting >> watchdog.log
goto begin
Carl
Re: Making .bat files to keep my servers on 24/7
Hey Carl! Thanks for the help, but so I downloaded the program. If I want to put it as high priority, what do I type to parameters? start /high -game cstrike?Hot Carl wrote:This was the .bat file I used with my Team Fortress server, it will work with CS also. You have to keep the computer logged in at all times unfortunately. I think eventually I began to use RunAsSvc instead so I didn't have to be logged in to run the server. http://www.pirmasoft.com/runassvc.php
Hope this helps!Code: Select all
@echo off title SRCDS Idle Watchdog/Updater cls echo (%date% %time%) Now starting SRCDS Watchdog/Updater echo (%date% %time%) Now starting SRCDS Watchdog/Updater >> watchdog.log :begin echo (%date% %time%) Checking for SRCDS updates echo (%date% %time%) Checking for SRCDS updates >> watchdog.log start /wait C:\tf2\hldsupdatetool.exe -command update -game tf -dir C:\tf2\rotation echo (%date% %time%) Starting server echo (%date% %time%) Starting server >> watchdog.log start /wait C:\tf2\rotation\orangebox\srcds.exe -game tf -console +maxplayers 24 -ip xx.xx.xx.xx -port 27015 echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting >> watchdog.log goto begin
Carl
And what do I choose for working dir?
Re: Making .bat files to keep my servers on 24/7
I use FireDaemon to run all of our servers on our VDS. Software is phenomenal, we have used it for years.
http://firedaemon.com/download-firedaemon.php
http://firedaemon.com/download-firedaemon.php
Re: Making .bat files to keep my servers on 24/7
Yes that should get the trick done, I never really kept our server at high priority. I played around with it a couple times but never saw any difference.fatality wrote:Hey Carl! Thanks for the help, but so I downloaded the program. If I want to put it as high priority, what do I type to parameters? start /high -game cstrike?Hot Carl wrote:This was the .bat file I used with my Team Fortress server, it will work with CS also. You have to keep the computer logged in at all times unfortunately. I think eventually I began to use RunAsSvc instead so I didn't have to be logged in to run the server. http://www.pirmasoft.com/runassvc.php
Hope this helps!Code: Select all
@echo off title SRCDS Idle Watchdog/Updater cls echo (%date% %time%) Now starting SRCDS Watchdog/Updater echo (%date% %time%) Now starting SRCDS Watchdog/Updater >> watchdog.log :begin echo (%date% %time%) Checking for SRCDS updates echo (%date% %time%) Checking for SRCDS updates >> watchdog.log start /wait C:\tf2\hldsupdatetool.exe -command update -game tf -dir C:\tf2\rotation echo (%date% %time%) Starting server echo (%date% %time%) Starting server >> watchdog.log start /wait C:\tf2\rotation\orangebox\srcds.exe -game tf -console +maxplayers 24 -ip xx.xx.xx.xx -port 27015 echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting echo (%date% %time%) WARNING: SRCDS quit or crashed, restarting >> watchdog.log goto begin
Carl
And what do I choose for working dir?
I'm sure you know this, but with RunAsSvc when you do updates/upgrades/etc you can just go into your services to start and stop the server as you wish. It has been a while since I messed around with it, but I always liked to use RunAsSvc because there wasn't any overhead.
I forgot to mention you can convert those .bat files into .exe files and have RunAsSvc run them. The reason why I converted them is so I could use Steamtools(Sourcemod plugin) to auto update the server.
I used it once but wasn't really too crazy about it, I think if you are running multiple servers it would probably be an awesome tool. We only had 1-2 servers up at any given time so it was a tad bit overkill.TacTicToe wrote:I use FireDaemon to run all of our servers on our VDS. Software is phenomenal, we have used it for years.
http://firedaemon.com/download-firedaemon.php
Carl
Re: Making .bat files to keep my servers on 24/7
Sorry I didn't read the full question:
Service Name : Counter-Strike Source
Description : CSS
Path to executable : C:\CSS\orangebox\SRCDS.exe
Parameters : -console -game "cstrike" -secure +map de_dust -autoupdate +log on +maxplayers 32 -port 27015 +ip 1.2.3.4 +exec server.cfg
Working Directory: C:\CSS\orangebox\
I'm gonna have to get back to ya on the "high" priority. When I wrote my first comment above I was thinking about when we used RunAsSvc with the .exe. Without the .exe RunAsSvc won't put that service in high priority. I think your only two options would be to make you bat file how you want then convert to .exe or use Firedameon.
Sorry for the double posting.
Carl
Service Name : Counter-Strike Source
Description : CSS
Path to executable : C:\CSS\orangebox\SRCDS.exe
Parameters : -console -game "cstrike" -secure +map de_dust -autoupdate +log on +maxplayers 32 -port 27015 +ip 1.2.3.4 +exec server.cfg
Working Directory: C:\CSS\orangebox\
I'm gonna have to get back to ya on the "high" priority. When I wrote my first comment above I was thinking about when we used RunAsSvc with the .exe. Without the .exe RunAsSvc won't put that service in high priority. I think your only two options would be to make you bat file how you want then convert to .exe or use Firedameon.
Sorry for the double posting.

Carl