Restarting a game server regularly frees memory and applies updates, but players must be warned. This tool writes the warning-and-restart script and the schedule for Linux (cron or systemd) or Windows.
How to use the tool
Choose the platform (cron, systemd or Windows), the restart time and the days.
Enter the warnings in minutes before the restart, the message and the game's chat command.
Fill in the RCON client (host, port), the save command and the service name.
Save each block in the file named in its comment, set MCRCON_PASS, then enable the schedule.
How the schedule works
The scheduled task starts at the first warning (restart time minus the largest delay). The script sends each warning, waits the difference between two warnings, saves, then restarts the service: with 30,15,5,1 minutes and a 04:00 restart, the task starts at 03:30. If the start time falls before midnight, days are shifted automatically. The script assumes an RCON client compatible with the “-H host -P port command” syntax (mcrcon); adapt the send() line for another client. The message syntax depends on the game: check it with the RCON command sheet.
sudo mkdir -p /etc/gameserver
echo 'MCRCON_PASS=ChangeMe!' | sudo tee /etc/gameserver/rcon.env
sudo chmod 600 /etc/gameserver/rcon.envFrequently asked questions
- Is the RCON password in the script?
- No. The script reads the MCRCON_PASS environment variable (recognised by mcrcon). Store it in a read-only file (chmod 600) or a Windows system variable.
- cron, systemd or Windows task?
- On Linux, systemd gives logs and error handling (journalctl); cron is simpler. On Windows, use Task Scheduler via schtasks.
