Schedule a Palworld server restart
Palworld's memory use grows with the number of bases and pals in the world and does not release it, which makes a dedicated server a strong candidate for a daily restart. It is one of the clearer cases where uptime and performance are directly opposed.
When should it restart?
Use {{minutes}} where the countdown number should go.
What happens, in order
- Job startsWarn
Broadcast Server restarting in 15 min - 10 min beforeWarn
Broadcast Server restarting in 10 min - 5 min beforeWarn
Broadcast Server restarting in 5 min - 1 min beforeWarn
Broadcast Server restarting in 1 min - Restart timeSave
Save - Restart timeStop
Shutdown 60 Scheduled restart
Shutdown takes a delay in seconds and its own message, so it can do the final countdown for you. Note the quirk in Broadcast: on many builds it truncates at the first space, so a multi-word warning arrives as one word. Test yours before trusting it, and fall back to the Shutdown message if it does.
The crontab line
Shifted 15 minutes earlier than your chosen time, so the restart itself lands on it rather than 15 minutes after.
45 3 * * * /opt/restart-palworld.sh
The script it runs
Save as /opt/restart-palworld.sh and make it executable. It assumes rcon-cli is on the path and reads the password from the environment rather than embedding it.
#!/usr/bin/env bash
set -euo pipefail
# Scheduled restart for Palworld.
# Generated by spawnly.net/tools/restart-scheduler
# The password stays out of this file. Put it in the environment, or in a
# file only root can read, and export it before this script runs.
RCON_HOST="${RCON_HOST:-127.0.0.1}"
RCON_PORT="${RCON_PORT:-25575}"
: "${RCON_PASSWORD:?set RCON_PASSWORD before running}"
send() {
rcon-cli --host "$RCON_HOST" --port "$RCON_PORT" --password "$RCON_PASSWORD" "$1"
}
# 15 minute warning
send 'Broadcast Server restarting in 15 min'
sleep 300
# 10 minute warning
send 'Broadcast Server restarting in 10 min'
sleep 300
# 5 minute warning
send 'Broadcast Server restarting in 5 min'
sleep 240
# 1 minute warning
send 'Broadcast Server restarting in 1 min'
sleep 60
# Flush the world to disk
send 'Save'
sleep 10
# Shut down cleanly
send 'Shutdown 60 Scheduled restart'
# Give the process time to finish writing before anything restarts it.
sleep 30
systemctl start palworld 2>/dev/null || trueCron uses the server’s timezone, not yours. Check it with timedatectl before assuming 04:00 means 04:00 where you are — a container in UTC and an admin in Europe are two hours apart in summer and one in winter.
The part specific to Palworld
Two quirks. Broadcast truncates at the first space on many builds, so a multi-word warning arrives as a single word — test yours before relying on it. And the Shutdown command takes a delay in seconds plus its own message, so it can run the final countdown itself; if Broadcast is unreliable on your build, use a long Shutdown delay instead of a warning ladder.