Palworld – Batch Script for Auto-Restarting Dedicated Servers

How to Auto-Restart Dedicated Servers

I don’t know if this will be useful for anyone else but this is the script I’m using to restart my own dedicated server.

This checks if the server is on every minute, as well as keeping a log file of when it restarts.

I also included a failsafe to restart the server every 24 hours.

@echo off
set "restart_interval=86400"  24 hours in seconds
set "log_file=ServerLog.txt"

:check_program
tasklist | find /i "PalServer.exe" > nul
if %errorlevel% neq 0 (
    echo [%DATE% %TIME%] Restarting the program. >> %log_file%
    taskkill /f /im "PalServer-Win64-Test-Cmd.exe"    
    taskkill /f /im "PalServer.exe"
    start "" "C:\<<INSERT PATH TO PALSERVER.EXE HERE>>\PalServer.exe"
) else (
    echo [%DATE% %TIME%] Program running normally. >> %log_file%
)

timeout /nobreak /t 60 > nul

set /a "elapsed_time+=60"

if %elapsed_time% geq %restart_interval% (
    echo [%DATE% %TIME%] Restarting the program every 24 hours. >> %log_file%
    taskkill /f /im "PalServer-Win64-Test-Cmd.exe"    
    taskkill /f /im "PalServer.exe"
    start "" "C:\<<INSERT PATH TO PALSERVER.EXE HERE>>\PalServer.exe"
    set "elapsed_time=0"
)
goto check_program

Just run the server, then run this program!

Helena Stamatina
About Helena Stamatina 2726 Articles
My first game was Naughty Dog’s Crash Bandicoot (PlayStation) back in 1996. And since then gaming has been my main hobby. I turned my passion for gaming into a job by starting my first geek blog in 2009. When I’m not working on the site, I play mostly on my PlayStation. But I also love outdoor activities and especially skiing.

Be the first to comment

Leave a Reply

Your email address will not be published.


*