BeamMP Server Watchdog

What it is:

I wrote a simple batch file to ensure my server instantly restarts if it crashes or the server window is manually closed (i.e. after config changes, or new mods added to /Resources/Client/, etc., for fast restart).

I use two instances of it on two servers concurrent.

What it is not:

An error handler.

What the batch file does:

  1. Prints usage info about itself
  2. Panic condition check
  3. Launches BeamMP-Server.exe and waits for it to crash or be manually closed
  4. If the server crashes or is manually closed, logs warning in console, backs up server.log, and instantly restarts BeamMP-Server.exe

How to use it:

  1. Extract batch file from .zip, place next to BeamMP-Server.exe
  2. Create shortcut to .bat on desktop
  3. Run shortcut

Where to get it:

Right here → (821 Bytes)

What it looks like:



Code is here for review:

//Provided by Dudekahedron - 2020

@echo off

color 07

SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
  set "DEL=%%a"

title BeamMP Server Watchdog
echo  Protecting BeamMP Server from crashes^^!
echo  Should you want to close BeamMP Server and this script:
echo    1. Close this window.
echo    2. Close the BeamMP Server window.
echo  _________________________________________________________________

IF NOT EXIST BeamMP-Server.exe (


) ELSE (




echo  [%date% - %time%] 
call :colorEcho 09 "   BeamMP Server started"

call :colorEcho 0A "   [MONITORING]"
start "BeamMP Server" /w BeamMP-Server.exe | set /p exitkey= ""

echo  [%date% - %time%]
call :colorEcho 0C "   [WARNING] BeamMP Server crashed, or was closed"

call :colorEcho 0E "   Backing up Server.log"

copy /V /Y Server_previous.log Server_previous_previous.log >nul
copy /V /Y Server.log Server_previous.log >nul

call :colorEcho 06 "   Restarting server"



echo  [%date% - %time%]

call :colorEcho 4F "[FATAL] BeamMP-Server.exe NOT FOUND - EXITING"



echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i

Any feedback or constructive criticism is welcome!


<standard caveat of non-liability, “use at own risk” type jargon>

1 Like

awesome, works, thanks :slight_smile:


@fillman86 this has been fixed.

@fillman86 thank you for the heads up, I will re-upload and correct that!

your link goes to a blank page “not found” downloading link errors out too

1 Like

@Dudekahedron said in BeamMP Server Watchdog:

Revised 10/5/2020:
I was considering adding in a timed restart as others have demonstrated but am going to instead opt to wait for servers to mature further so I won’t need to remove it in the future.

Called it.

This works fine with Server 1.0.

@Dudekahedron i mean its just like every other game server I’ve ever hosted. You gotta give your router time to realize the computer isn’t hosting it anymore. It’ll close the port which frees it up. Once the server opens it will reopen the port. Restarting instantly is how you get port conflicts. Also known as “Already in use” issues. Hadn’t ran across it yet but could be why so many get stuck at loading.

@SPJESTER This is interesting, thank you for your input. I haven’t run into any issues with ports, can you explain a bit more about how this helps?

added a timeout of 6 seconds to give the port time to fully close.

call :colorEcho 06 " Restarting server"
timeout 6

1 Like

Revised 10/5/2020:
Small change. A while back I started appending logs from CobaltEssentials into the standard Server.log instead of creating two separate logs and so I’ve simply uploaded an update of this batch file that doesn’t bother checking for a cobalt.log at all. Still has the panic condition and other late changes. I was considering adding in a timed restart as others have demonstrated but am going to instead opt to wait for servers to mature further so I won’t need to remove it in the future.

I would be interested in a bash version of this for the real server hosters out there.

Hey that’s great to hear! If you’ve got suggestions on improvements I’m always open to it.

Nice work here. Considering moving the official servers to this!

1 Like

Revised 8/10/2020:
Found stuff to change!
BeamMP debug logs are much more useful now, and the logs the Watchdog makes when debug=true in Server.cfg will not become massive.
Tossed in a panic condition when BeamMP-Server.exe is not found so that you don’t get batch-bombed if used incorrectly.
Cleaned up timestamps, got rid of mode setting (just because I like the window size doesn’t mean others will), and refined colors.
I have set up my copy of CobaltEssentials (Thanks, @Preston!) to create a Cobalt.log file, so if you happen to have done the same somehow, this will also create backups of that as well, but the log file must be named Cobalt.log. If you do not have a Cobalt.log it will skip this, as there is nothing to backup.

1 Like

Revised 7/28/2020:

Made Server.log backup system better - keeps current and two most recent logs.
Made the :rainbow: colors easier to look at.
I can’t really think of anything else at this point, as far as I can tell, this should really enable a server to have >99% uptime unless the computer running the server itself somehow has a failure.
I’ve had good success using it to quickly do restarts when troubleshooting a new command, and I’ve had a one actual crash → restart so far and it didn’t skip a beat.
Hopeful for more flexible server debug output in the future so logs don’t get massive.

1 Like

Revised 7/27/2020:

Cleaned house
Titled the protected BeamMP-Server console properly
Added t e c h n i c o l o r
Most recent Server.log is now dumped to Server_bak.log on crash or close (might get gnarly with huge debug logs?)

Haven’t had chance to try this yet, but really awesome idea, thank you for sharing it with us! :smiley:

1 Like