23 Oct
If you are running a CSS server on linux, the server itself already supports auto restarting srcds when crash. However on Windows, you can do it via a batch file. It works but it has its problems in doing that which I’ll explain further.
This is the batch file that you need to run to keep srcds.exe open by automatically running when crashed or closed.
@echo off
cls
echo Protecting srcds from crashes...
echo If you want to close srcds and this script, close the srcds window and type Y depending on your language followed by Enter.
title srcds.com Watchdog
:srcds
echo (%time%) srcds started.
start /wait srcds.exe -console -game cstrike +map de_dust +maxplayers 16
echo (%time%) WARNING: srcds closed or crashed, restarting.
goto srcds
The command above will monitor for srcds.exe and immediately auto runs the command line if it’s not running. Well Valve recommends that we should wait for at least 10 seconds before restarting so that there is enough time for the memory to clear up. I’ve used this batch and noticed that there were a few times the server crashes, restart, crashes again and restart. Previously I’ve written an article that contains a couple of free tools that can auto rerun program when closed but this time I needed something different.
I was looking for a free, small, simple and portable tool that can monitor for a specific process and then run a “different” file when it detects a crash. I found Restart on Crash which has been working perfectly ever since I started using it. Restart on Crash is an monitoring tool that will watch the applications that you specify and automatically relaunch any program that hangs or crashes. You can add any number of applications to monitor, enable/disable them individually and edit the command line that will be used to restart an application. Restart on Crash doesn’t require installation and stores all it’s configuration data in a “settings.ini” file in the program’s folder, so it’s portable. It should be compatible with most NT-based Windows versions.
Basically the below image is the settings for the srcds server. It monitors srcds.exe and when it isn’t running, a run.bat file will be executed.

The more interesting part is the run.bat which is executed when the program detected that srcds.exe is not running. Since it is a batch file, I can program it to run multiple commands.

The first command shows that I ping localhost 3 times. This command is being used as a feature to wait for 3 seconds before going to the second command. The second command from the batch file is to execute CleanMem which is a tool to clean process and file cache to recover even more memory and performance. Then again pause for 10 seconds before running srcds.exe with the full command line. This method has been working perfectly for weeks already and I didn’t need any other more advanced crash recovery software such as Firedaemon that cost money.
Technorati Tags: restart, crash, firedaemon, srcds, windows
: Copying this article to your website is strictly NOT allowed. However, if you like this article, you can use the HTML code below to directly link to this article.
Disable Program Has Stopped Working Error Dialog in Windows Server 2008 Sending Email Using Command Line Useful for Downtime Alert Notification Keep Application Running by Automatically ReRun When Closed Shut down Unnecessary Services and Programs with AlacrityPC Automatically Close Running Programs and Eject USB PenDrive Angsuman’s Translator Plugin Pro causing High Load for servers Nero 7.2.3.2b fixes audio CD skipping problem
Have computer technical problems? Get FREE help from Raymond.CC FORUM
6 Responses for "Execute any File When Application Crashed or Stopped Running (Useful for SRCDS)"
Very Useful!
I have a problem using this tool.
I choose an application on “MONITOR THIS APPLICATION”..for example opera.exe
after i wish if Opera isn’t running to run Firefox by a run.bat
the problem is that when i choose the run.bat the same run.bat appears in the box MONITOR THIS APPLICATION
i don’t understand
I find the solution
I have to modify manually the box in witch I run run.bat
ALL is ok now
It’s great
it will be usefull for when i set up a counter strike in my home
do you think its possible fro me to set up at home via wireless connection?
Raymond, I really like the use of CleanMem that you’ve implemented. I’m going to give Shane a call and tell him about it.
Just out of curiousity are you running CleanMem with the “Clear File Cache” option enabled or disabled? If you’ve tried it both ways for this server have you noticed any positive or negative impact either way?
Oh yeah, welcome back from the honeymoon and congrats!
-Evan
http://www.PcWinTech.com – Home of CleanMem
I’ll keep this in mind. Hopefully I can use it when I host a CS Server.
Leave a reply