Schedule a Don't Starve Together server restart
Don't Starve Together is designed to run continuously — the world advancing while nobody is playing is the point. Restarts are about memory reclamation over long uptimes rather than about anything the game needs.
When should it restart?
Use {{minutes}} where the countdown number should go.
What happens, in order
- Job startsWarn
c_announce("Server restarting in 15 min") - 10 min beforeWarn
c_announce("Server restarting in 10 min") - 5 min beforeWarn
c_announce("Server restarting in 5 min") - 1 min beforeWarn
c_announce("Server restarting in 1 min") - Restart timeSave
c_save() - Restart timeStop
c_shutdown()
The console takes Lua, which is why these look like function calls. In a cluster with caves you must send the sequence to every shard — each one is a separate server with its own world to save.
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-dst.sh
The script it runs
Save as /opt/restart-dst.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 Don't Starve Together.
# 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:-10998}"
: "${RCON_PASSWORD:?set RCON_PASSWORD before running}"
send() {
rcon-cli --host "$RCON_HOST" --port "$RCON_PORT" --password "$RCON_PASSWORD" "$1"
}
# 15 minute warning
send 'c_announce("Server restarting in 15 min")'
sleep 300
# 10 minute warning
send 'c_announce("Server restarting in 10 min")'
sleep 300
# 5 minute warning
send 'c_announce("Server restarting in 5 min")'
sleep 240
# 1 minute warning
send 'c_announce("Server restarting in 1 min")'
sleep 60
# Flush the world to disk
send 'c_save()'
sleep 10
# Shut down cleanly
send 'c_shutdown()'
# Give the process time to finish writing before anything restarts it.
sleep 30
systemctl start dst 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 Don't Starve Together
The console takes Lua, which is why the commands look like function calls. The important part is the cluster: a world with caves runs as two separate servers with two separate saves, and the sequence must reach both. Sending it only to the master shard saves the surface and abandons everything underground.