Welcome, Visitor!

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

How to Auto Restart a Palworld Dedicated Server

palworld

Administrator
Staff member
Joined
Jan 19, 2024
Messages
151
Keeping your Palworld server running smoothly is essential for a great multiplayer experience. One of the key practices for server maintenance is regularly restarting it. This guide will walk you through setting up an auto-restart feature for your Palworld dedicated server.

Firstly, download our Batch script to your Server.
fed045f6eaac898c6a29ab96d1d33545850c2cc0[1].jpeg

Right-click on the file while it is selected, and click Edit.
f2ce7bbfbd220e689a0cec2aa504883ff4a83372[1].png

Then, modify the values to match your Palworld server’s file path and the desired restart schedule.
f9279009c6a88ddeeb66b01ff89a812a74b7870f[1].png

Now save the file and run by double-clicking to file.

The batch script download link: https://cdn.discordapp.com/attachme...d_Server_Auto_Restart_-_palworldforum.com.bat
 
Last edited:

pfeng8

New member
Joined
Jan 26, 2024
Messages
9
ping your Palworld server running smoothly is essential for a great multiplayer experience. One of the key practices for server maintenance is regularly restarting it. This guide will walk you through setting up an auto-restart feature for your Palworld dedicated server.

Firstly, download our Batch script to your Server.
Uh… where’s the batch script?
 

pfeng8

New member
Joined
Jan 26, 2024
Messages
9
Code:
@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
Nevermind, I thought I’d check here to see if there was something to improve my own script but I’ll just post my script if it helps anyone out.

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. Just run PalServer.exe, then run this batch script.
 

R3Dlol

New member
Joined
Jan 27, 2024
Messages
3
is there a way in that script to notify ingame players that the server will restart soon?
 

memzi

New member
Joined
Jan 27, 2024
Messages
21
A few great ways of achieving a server restart being stated in this thread! I like @pfeng8 script since it checks if the service has crashed. I may implement this myself!

I keep it simple with a “shutdown -r” bat script in task scheduler and have it run every morning at 5AM, with the server executable as a startup program. It’s nice and simple and works!

The advantage to restarting the OS and not just the service is that you are also clearing out your RAM when restarting the OS. Restarting the service alone will clear out entities which will definitely help performance, but there is also a little bit of overhead in RAM when the system hasn’t restarted in some time.

Some might be worried about how this affects game saves, worrying of corruption or a deleted save. Looking in event viewer it appears it shuts down the Palworld service gracefully, limiting this risk. Even if it didn’t, I run backups every 15 minutes using robocopy to copy the save files to a network drive. I’ve been thinking about doing a small post on how to achieve this.
 

detrovi

New member
Joined
Jan 23, 2024
Messages
12
I just setup a 4 hour scheduled task for my private server using the below Powershell. Make sure to update your PalServer path.

I’m noticing a significant memory leak since Thursday’s patch. Just applied today’s, we’ll see if it resolves the issues. Server was crashing after about 3-4 hours of run time.

See below Powershell. I saved this in C:\Scripts on my PC, then setup a scheduled task with triggers for 8am, 12pm, 4pm, 8pm, 12am and pointed it at the PS script.

Code:
# PowerShell Script to Manage Palworld Server

# Path to the Palworld Server executable
$serverPath = "D:\Steam\steamapps\common\PalServer"
$serverExecutable = "PalServer.exe"
$consoleExecutable = "PalServer-Win64-Test-Cmd.exe"

# Function to Start the Palworld Server
function Start-PalworldServer {
    Write-Host "Starting Palworld Server..."
    Start-Process -FilePath "$serverPath\$serverExecutable"
    Write-Host "Palworld Server started."
}

# Function to Stop the Palworld Server
function Stop-PalworldServer {
    Write-Host "Stopping Palworld Server and associated console..."
    
    # Stop the PalServer process
    Stop-Process -Name "PalServer" -Force
    
    # Stop the associated Console Window Host process
    Get-Process | Where-Object { $_.Path -eq "$serverPath\Pal\Binaries\Win64\$consoleExecutable" } | Stop-Process -Force

    Write-Host "Palworld Server and console stopped."
}

# Stopping the server and console
Stop-PalworldServer

# Waiting for 30 seconds
Write-Host "Waiting for 30 seconds..."
Start-Sleep -Seconds 30

# Starting the server
Start-PalworldServer
 
Last edited: