Automatic restarts for a ARK: Survival Evolved server
No game benefits more from scheduled restarts than ARK, and no game punishes a sloppy one more. Memory rises steadily as dinos and structures accumulate, and a server left running for a week will be noticeably worse than one that restarts every day.
When should it restart?
Put {{minutes}} wherever the number of minutes left should appear.
What happens, in order
- Job startsWarn
ServerChat Server restarting in 15 min - 10 min beforeWarn
ServerChat Server restarting in 10 min - 5 min beforeWarn
ServerChat Server restarting in 5 min - 1 min beforeWarn
ServerChat Server restarting in 1 min - Restart timeSave
SaveWorld - Restart timeStop
DoExit
Always send SaveWorld and wait for it to return before DoExit. ARK does not reliably save on shutdown, and this is the single most common cause of a rolled-back tribe base.
The crontab line
Moved 15 minutes ahead of the time you picked, so the restart happens at that time instead of 15 minutes later.
45 3 * * * /opt/restart-ark_se.sh
The script it runs
Save it as /opt/restart-ark_se.sh and mark it executable. It expects rcon-cli on the path and takes the password from an environment variable instead of storing it in the file.
#!/usr/bin/env bash
set -euo pipefail
# Scheduled restart for ARK: Survival Evolved.
# Generated by spawnbench.com/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:-27020}"
: "${RCON_PASSWORD:?set RCON_PASSWORD before running}"
send() {
rcon-cli --host "$RCON_HOST" --port "$RCON_PORT" --password "$RCON_PASSWORD" "$1"
}
# 15 minute warning
send 'ServerChat Server restarting in 15 min'
sleep 300
# 10 minute warning
send 'ServerChat Server restarting in 10 min'
sleep 300
# 5 minute warning
send 'ServerChat Server restarting in 5 min'
sleep 240
# 1 minute warning
send 'ServerChat Server restarting in 1 min'
sleep 60
# Flush the world to disk
send 'SaveWorld'
sleep 10
# Shut down cleanly
send 'DoExit'
# Give the process time to finish writing before anything restarts it.
sleep 30
systemctl start ark_se 2>/dev/null || trueHeads up: cron follows the server clock, not your local time. Check with timedatectl first. A container set to UTC and an admin living in Europe differ by two hours in summer and by one in winter, so 04:00 may not be the 04:00 you had in mind.
Advertisement
What is different about ARK: Survival Evolved
Send SaveWorld, wait until it returns, and only then send DoExit. ARK cannot be trusted to save as it shuts down — that is the most common reason a tribe logs in to find a day's work missing, and it is completely avoidable. In a cluster, every map is its own server with its own save, so each one needs the whole sequence.
Advertisement
Setting up RCON
The script talks to the server over RCON, turned on with ?RCONEnabled=True and ?RCONPort=27020 on the launch line. It signs in with ServerAdminPassword, the same password used for admin commands in game, so change that from any default before enabling RCON and keep 27020 closed on the router.
How long to wait after SaveWorld
SaveWorld writes the map's .ark file in ShooterGame/Saved/SavedArks/, and on a mature server that takes long enough that a script waiting a fixed few seconds can send DoExit too early. Time a save on your own server by watching the file's modified time, then wait comfortably longer than that. Run the update for app 376030 in SteamCMD between stop and start so the server comes back on the version players have.
Settings changes and restarts
The server writes its configuration back to disk when it stops, so a GameUserSettings.ini edited while it is running is overwritten at the next shutdown. A scheduled restart is the natural time to apply changes: let it stop, edit, then start.