Schedule a Valheim server restart
Valheim servers benefit from a restart on a long uptime, but the game gives you almost nothing to do it gracefully with. The dedicated server has no remote console at all.
When should it restart?
Valheim has no remote console, so a script cannot warn your players or trigger a save. What is left is a clean process signal, which this game does handle correctly. The schedule below therefore runs at exactly the time you set, with no lead time, because there is no countdown to run.
What happens, in order
- Restart timeStopSIGTERM to the process, then wait for it to exit on its own
Valheim’s dedicated server has no remote console, so there is no way to warn players from a script and no save command to send. The restart is a clean process signal and nothing else — which the server does handle correctly, saving the world as it shuts down.
The crontab line
No lead time needed — there is no countdown before the restart.
0 4 * * * /opt/restart-valheim.sh
The script it runs
Save as /opt/restart-valheim.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 Valheim. # Generated by spawnly.net/tools/restart-scheduler sleep 10 # Valheim has no console, so stop it the way its service manager would. systemctl restart valheim || pkill -TERM -f valheim
Cron 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 Valheim
There is no way to warn players from a script and no save command to send. What Valheim does do correctly is save on a clean shutdown, so a SIGTERM — which is what a systemctl restart sends — leaves the world intact. Do not use a kill signal that skips that, and do not schedule anything during hours people play, because the first warning anyone gets will be the disconnect.