AutoRestart: Reliable Scheduler for Minecraft Server on Linux

Keeping Your Fabric Server Fresh with Automated Restarts on Linux Running a Minecraft server is a labor of love. You tweak the mods, balance the mechanics, and build a thriving community across sprawling biomes. But even the most optimized Fabric server can start to lag after hours of chunk gener...

Download SERVER RESTART for Minecraft 1.19.3

Original name: SERVER RESTART

Minecraft: 1.19.3

FileVersionLoaderSize
SERVER-RESTART.zip1.19.3—1 КБDownload

Keeping Your Fabric Server Fresh with Automated Restarts on Linux

Running a Minecraft server is a labor of love. You tweak the mods, balance the mechanics, and build a thriving community across sprawling biomes. But even the most optimized Fabric server can start to lag after hours of chunk generation and redstone contraptions. Memory leaks, tick rate drops, and general instability are the silent griefers of any long-running world. That is where a smart auto-restart scheduler comes in. By periodically rebooting your server, you clear out memory bloat and keep performance snappy. For Linux-based Fabric setups, systemd timers provide a rock-solid, built-in way to automate restarts without relying on outdated mods that might not work with your version.

Why Use a Script Instead of a Mod?

While there are a handful of Fabric mods that claim to handle scheduled restarts, many are abandoned, incompatible with Minecraft 1.19.2 and beyond, or simply fail to fire reliably. Server owners often spend hours troubleshooting a mod that should just work, only to find it silently skips the restart cycle. The script approach using systemd services and timers is lightweight, transparent, and completely under your control. You can tailor restart warnings, specify exact times, and even stagger them across multiple worlds. Plus, it works on any Linux distribution—Ubuntu, Debian, CentOS—as long as you have systemd and screen installed.

What You Will Need Before Starting

  • A dedicated Linux server (or VPS) with SSH access and basic command-line familiarity.
  • A running Fabric Minecraft server, preferably launched inside a screen session.
  • Root or sudo privileges to create and enable systemd unit files.
  • The server JAR file path and the exact startup command you normally use.

If you are new to server administration, do not worry. The steps are straightforward, and once set up, you will wonder how you ever lived without automatic restarts. For those who prefer a graphical launcher to handle modpacks and server tools, the foxygame.net launcher offers a modern, intuitive interface where you can download and manage everything from a single menu, making it a perfect companion for both client and server management.

Step-by-Step: Building Your Auto-Restart System

1. Understanding the Systemd Components

The setup relies on four custom files: a service unit for the Minecraft server itself, a oneshot service that triggers the restart, and two timer units that schedule the restart and the warning message. All files live in /etc/systemd/system/. The main service runs your server inside a named screen session (mc), while the oneshot service sends a stop command to that screen, waits, and then restarts the main service. The timers use OnCalendar directives to fire at your chosen intervals.

2. Crafting the Minecraft Service File

Download the provided minecraft.service template and edit these key lines:

  • User=root: Change root to the Linux user that owns the server files.
  • WorkingDirectory=/root/mcserver/fabric: Point this to your server directory, where the JAR lives.
  • ExecStart=screen -S mc -d -m java -Xmx6G -jar fabric-server-mc.1.19.2-loader.0.14.19-launcher.0.11.2.jar nogui: Adjust the RAM allocation (-Xmx6G) and the JAR filename to match your exact setup. The screen name mc must remain consistent across all files.

Save the file. This unit will now launch your Fabric server in a detached screen session whenever it is started or restarted.

3. Scheduling the Restart Timer

Open minecraft.timer. In the [Timer] section, add your desired restart times using the OnCalendar format. For example, to restart every 3 hours daily:

OnCalendar=*-*-* 00/3:00:00

You can also specify specific days and times:

OnCalendar=Mon..Fri 19:00
OnCalendar=Sat..Sun 22:00

Remember that the timer uses the server’s timezone, not your local clock. Run date via SSH to check the current server time and calculate the offset if needed.

4. Adding a Warning Message

Nobody likes being kicked mid-build. The restartwarning.service sends a chat message to all players one minute before the restart. Edit the line:

ExecStart=screen -p 0 -S mc -X eval 'stuff "say SERVER WILL RESTART IN 1 MIN, PLEASE LOG OFF NOW."\\015'

Change the text inside the quotes to your own warning, but keep the \\015 at the end—it simulates pressing Enter in the console. Then configure restart-warning.timer to fire 1 minute (or 5 minutes) before the actual restart timer. If your restart is at 19:00, set the warning timer to 18:59.

5. Deploying and Enabling the Units

Upload all four files to /etc/systemd/system/. Then run these commands in order:

  • systemctl daemon-reload
  • systemctl enable minecraft.service
  • systemctl start minecraft.service
  • systemctl enable oneshot.service
  • systemctl enable minecraft.timer
  • systemctl enable restartwarning.service
  • systemctl enable restart-warning.timer
  • systemctl start minecraft.timer
  • systemctl start restart-warning.timer

Check the status with systemctl status minecraft.service; you should see an “active (exited)” state, which is normal for a forking service. Verify the screen session with screen -ls—you should see a session named mc. Attach to it with screen -r mc to watch the console, and detach with Ctrl+A followed by D.

Troubleshooting Common Pitfalls

If the server does not restart, double-check that all file paths are absolute and that the JAR filename matches exactly. Also ensure the oneshot.service is correctly linked to the main service via the BindsTo and After directives. The timer units must be enabled and started; a common mistake is enabling but forgetting to start them. Use systemctl list-timers to see when the next trigger is scheduled.

For older Minecraft versions or Forge servers, this method still works, though Forge users might prefer dedicated mods. However, if you value a clean, mod-free server environment, these scripts are a reliable alternative that never goes out of date.

Conclusion: A Set-and-Forget Solution for Server Stability

Automating restarts on a Linux Fabric server might sound intimidating, but with systemd timers, you gain precise control over your server’s uptime and player experience. The warning system keeps your community informed, while the regular reboots keep chunk loading smooth and TPS high. Once configured, the whole process runs silently in the background, just like a well-tuned redstone clock. Whether you are hosting a small survival world or a large modded network, this scheduler is an essential tool in your admin kit. Take the time to set it up once, and your server will thank you with fewer crashes and happier players.