This guide shows you how to set up an automatic restart for your Rust server that warns players in chat before it happens. You’ll configure a script that counts down, sends warnings, then restarts the server process. You’ll need basic command-line knowledge and access to your server’s file system (via SSH or a control panel).
What You’ll Need
- A Rust dedicated server (Windows or Linux) with RCON enabled.
- RCON password and port from your server config.
- A way to run scheduled tasks (cron on Linux, Task Scheduler on Windows).
- Basic scripting ability (Bash or PowerShell).
- An RCON client tool or use a simple script with a tool like
rcon-cli(optional).
Step-by-Step
- Enable RCON in your server config. Locate your
server.cfgfile (usually in the server root). Add or set these lines:rcon.port 25575rcon.password your_secure_passwordrcon.web 1(if you want web RCON). Save the file and restart the server once to apply. - Test RCON connectivity. From your local machine, use an RCON tool (like WebRCON or a command-line client) to connect. Send a simple command like
statusto verify it works. - Create the restart script. Choose a location on your server, e.g.,
/home/rust/restart.sh(Linux) orC:\rust\restart.ps1(Windows). The script will: send warnings, wait, then kill and restart the server process. - Write the warning logic. In the script, use RCON to send chat messages. For example, using a command-line RCON client:
rcon-cli --host localhost --port 25575 --password yourpass say "Server restart in 10 minutes"
Repeat for 5, 2, and 1 minute warnings. - Add the restart command. After the warnings, stop the server gracefully. On Linux, send
saveandquitvia RCON, then wait for the process to exit. On Windows, usestopor sendquitvia RCON. Then start the server again with the same command you normally use (e.g.,./RustDedicated -batchmode +server.port 28015). - Schedule the script. On Linux, use cron:
crontab -eand add a line like0 4 * * * /home/rust/restart.shto run daily at 4 AM. On Windows, use Task Scheduler to run the PowerShell script at your desired time. - Test the script manually. Run the script once while the server is running. Verify that warnings appear in game chat and that the server restarts successfully. Watch for any errors.
- Monitor and adjust. Check server logs after the scheduled restart to ensure it went smoothly. Adjust the warning times or schedule as needed.
Common Mistakes
- RCON not enabled: Forgetting to set
rcon.portandrcon.passwordin server.cfg. - Wrong RCON port: Using the game port (28015) instead of the RCON port (25575).
- Script not executable: On Linux, forgetting to
chmod +x restart.sh. - Incorrect path to server executable: The script uses a relative path that fails when run from cron (which uses a different working directory). Use absolute paths.
- Not waiting for the server to stop: Killing the process immediately after sending
quitcan corrupt saves. Always wait for the process to exit gracefully. - Hard-coding the password in the script: This is a security risk if the script is readable by others. Use environment variables or a protected config file.
Tips
- Use a dedicated RCON client script: Tools like
rcon-cli(Python) ormcrcon(C) are reliable and easy to call from scripts. - Add a final 30-second warning: Players appreciate a last call before the server drops.
- Log the restart: Have the script append a timestamp to a log file for troubleshooting.
- Test the script during low population times: Avoid disrupting active players when testing.
- Consider using a server manager: Tools like BattleMetrics or RustAdmin offer built-in scheduled restarts with warnings, which can be easier than scripting.
Troubleshooting
- Warnings not appearing in chat: Check that the RCON command is correct. Use
say(notchat.say). Verify the RCON connection is working by sending astatuscommand. - Server doesn’t restart: Check the script’s path to the server executable. Make sure the script has permission to execute it. Look at the server logs for errors.
- Server crashes during restart: Ensure you wait long enough for the server to save and shut down. Increase the sleep time after sending
quit. - RCON connection refused: Verify the RCON port is open and the password is correct. Check that the server is running and RCON is enabled.
- Cron job doesn’t run: Check the cron logs (usually
/var/log/syslog) for errors. Ensure the script is executable and the path is correct. - Script works manually but not via cron: Cron runs with a minimal environment. Use absolute paths for everything, and set the
PATHvariable inside the script if needed.
Frequently Asked Questions
Can I use this method with a hosting provider?
Yes, if your host gives you SSH or file access and allows you to run custom scripts. Some hosts have built-in scheduled tasks; check your control panel.
How do I change the warning messages?
Edit the script and modify the text inside the say commands. You can also add more warnings by duplicating the lines.
Will this work with modded servers (e.g., Oxide)?
Yes, the RCON say command works the same. However, some mods might interfere; test it.
Can I set different restart times for different days?
Yes, use multiple cron entries or a more complex scheduling script (e.g., using if statements to check the day of the week).
Is it safe to kill the server process if it hangs?
It’s safer to send quit and wait. If the server is unresponsive, you may need to force kill, but that risks losing unsaved data. Use a timeout in your script.
Do I need to install any extra software?
You need an RCON client tool. Many are available as standalone executables or Python scripts. Alternatively, you can use a simple Python script with the rcon library.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- How to Choose an Amplifier for Magico A3 Speakers
- How to Ban a Player from Your FiveM Server
- Pokemon Go Friend Codes: How to Add & Use Them33.33 XP/day
- Google Algorithm Change: Original Reporting Boost
- Create Folder for Selected Item on Mac: Full Guide
- Data Center Location Questions for AI Workloads