Project Zomboid

Project Zomboid

Baphanax Oct 8, 2024 @ 6:22pm
~Free~ Auto Restart Script - .bat
So I was searching for an easy way to get an Auto Server restart script working on my dedicated server and a lot of them seemed to be very long and drawn out tutorials, after a couple hours and some researching I made a .bat file which can be created in Notepad and run from the same folder that your Start64.bat file is in.

When saving the file save it as all files and make sure it has the .bat signature at the end.

Make sure your server path is correct

Double click and run the auto restart program :-)

It's been working for me now for a couple days very well and I use it with udderly up to date. If you guys run into any problems lmk!
----------------------------------------------------------------------------------------

@echo off
setlocal

set "serverPath=C:\Users\yourfolder\steamapps\common\Project Zomboid Dedicated Server"
set "serverExe=java.exe" :: Check for the Java process
set "restartDelay=30" :: Time to wait before restarting server (in seconds)
set "checkInterval=120" :: Interval to check if the server is running (in seconds)

:Start
cd /d "%serverPath%"

:: Start the server
echo Starting the server...
start "" "C:\Users\yourfolder\steamapps\common\Project Zomboid Dedicated Server\StartServer64.bat"

echo Server Loading, waiting to check...
:: Initial wait for server to load
timeout /t 68 /nobreak >nul

:Monitor
:: Check if the server is still running
echo Checking if server is running...
tasklist | find /I "%serverExe%" >nul
if errorlevel 1 (
echo The server has crashed!! Restarting in %restartDelay% seconds!!
timeout /t %restartDelay% /nobreak >nul
goto Start
)

:: If the server is still running, wait and check again
echo Server is running. Checking again in %checkInterval% seconds...
timeout /t %checkInterval% /nobreak >nul
goto Monitor
Last edited by Baphanax; Oct 8, 2024 @ 6:30pm
< >
Showing 1-1 of 1 comments
TheDdon Feb 13 @ 5:22am 
hey boss. how has it been holding up with your script? (please bear with me as im such a noob in these parts)
questions:
- so i run this script after starting the server?
- does this work like some auto restart scripts that goes in a loop every x number of hours?
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Oct 8, 2024 @ 6:22pm
Posts: 1