Automatic restarts for a ARK: Survival Ascended server
Survival Ascended keeps Survival Evolved's hunger for memory and adds the heavier baseline of its newer engine. On a busy server a scheduled restart is not a nice extra — it is simply part of running the thing.
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
Same as Survival Evolved: SaveWorld first, wait, then DoExit. Ascended writes a larger world and takes correspondingly longer.
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_sa.sh
The script it runs
Save it as /opt/restart-ark_sa.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 Ascended.
# 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_sa 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 Ascended
Same rule as Survival Evolved: SaveWorld, wait, then DoExit. It matters even more on Ascended, where world files are larger and slower to write. Leave the save plenty of time before the stop command, and leave the process plenty of time before anything tries to start it up again.
Advertisement
Setting up RCON
The warnings and the save are sent over RCON, enabled on the launch line with ?RCONEnabled=True and ?RCONPort=27020. There is no separate RCON password; it uses ServerAdminPassword, so change that from any default before enabling RCON. Keep 27020 closed on the router; the script talks to it from the machine itself.
Running the script on Windows
The commands are the same wherever the server runs, because they go over RCON rather than through the operating system. The cron line on this page suits a Linux host running Ascended under Proton. On a Windows machine, put the same sequence in a script, send the commands with any command-line RCON client, and run it from Task Scheduler instead of cron.
Confirm the save before the stop
SaveWorld writes the map's .ark file in ShooterGame/Saved/SavedArks/. On a mature server that takes long enough that a script waiting a fixed few seconds can send DoExit too early. Watch how long a save takes on your server, by checking when the file's modified time changes, and wait comfortably longer than that before stopping.
Do not edit settings while it is running
The server writes its configuration back to disk when it shuts down, so a GameUserSettings.ini edited while the server runs is overwritten at the next stop. A scheduled restart is a convenient moment to apply changes: stop, edit, then start.