This mod restarts the Minecraft server by itself or with an external restart script.
The mod can only be used on server side and won't work on the client side.
You need a server to play with friends? You don't know how to set up one? Just rent an already configured server!
Click on the picture above, select a plan (with recommended at least 6 GB),
use my code agent to get 25% off your first month and enjoy playing with your friends!
Support
Support: Supported Minecraft Versions
New Development and Fixes: 1.19.3
Bug Fixes: 1.18.2
Critical Bug Fixes: 1.17.1, 1.19-1.19.2
End of Support: 1.14.X-1.16.X, 1.18-1.18.1
Features
- Restarting the server at specified times
- Restarting the server with a delay, if it is empty
- Restarting the server, if the tps are below a specified level for a specified time
Server Config
The config file can be found in the "serverconfig" folder in the "world" folder and is named "auto_restart-server.toml".
- restart
Options for restarting:
- use_external_restart_script
Is the server started by an external restart script?
- restart_command
Command that is executed on Server stopped to restart the server. Only called if "use_external_restart_script" is false.
- auto_restart
Option for auto restarting:
- enabled
Should the Server do automatic restarts?
- times
Times in 24-hour format on which the server will automatically restart.
Examples: "14:00", "16:32"
- on_crash
Should the server be automatically restarted when it crashes.
- warning_times
Times before an auto restart of the server, a restart warning should be shown.
Examples:
- 5s - For a message 5 seconds before a restart
- 7m - For a message 7 minutes before a restart
- 2h - For a message 2 hours before a restart
- on_empty_restart
Options for restart, if the server is empty:
- enabled
Should the server restart, if no players are online?
- delay
Delay after the server should restart, if it is empty.
Examples:
- 5s - For a delay 5 seconds
- 7m - For a delay 7 minutes
- 2h - For a delay 2 hours
- low_tps_restart
Options for restart, if the tps of server or its dimensions are low:
- enabled
Should the server restart, if it is below a tps level for a specified time?
- minium_tps_level
TPS level below which the server is restarted, if it lasts for the specified time.
- delay
Delay, that the server must be below the defined TPS level, in order for it to be restarted.
Examples:
- 5s - For a delay 5 seconds
- 7m - For a delay 7 minutes
- 2h - For a delay 2 hours
Commands
- /restart
Restarts the server
How to use the Restart Mod
You can let the mod use the restart command to restart the server, or use an external restart script.
The script examples are Linux sh scripts.
You can find Windows script examples on: https://github.com/GeheimagentNr1/AutoRestart/wiki/Windows-Scripts
Restart Command
These scripts are for the use, if you have configured, that you are using an external restart script.
The first script is named "restart_start.sh". It is used to start the "restart_loop.sh" script in a screen.
bash -c 'cd <Path of your Minecraft server>; screen -d -m -S <Name of your Screen, i.e. your folders name without spaces> java -jar forge-<Minecraft version>-<Forge version>.jar'
External Restart Script
These scripts are for the use, if you have configured, that you are using an external restart script.
The first script is named "restart_start.sh". It is used to start the "restart_loop.sh" script in a screen.
bash -c 'cd <Path of your Minecraft server>; screen -d -m -S <Name of your Screen, i.e. your folders name without spaces> ./restart_loop.sh'
The "restart_loop.sh" script has the logic in it, to restart or stop the server. It will restart the server always, except in the "./auto_restart/restart" file is "0".
The Auto Restart Mod writes "-1", "0" or "1" to the file.
When the script reads the file,
- "-1" means that server crashed.
- "0" means the server was shutdown with the "/stop" command and should be stopped.
- "1" means the server that the server was stopped with the "/restart" command or an auto restart and should be restarted.
After the server was stopped for a restart, the script waits 5 seconds until it restarts the Minecraft server.
while true
do
java -Xmx<Amount of RAM in gigatytes you want to allocate to Minecraft>G -jar forge-<Minecraft version>-<Forge version>.jar
read -r should_restart < ./auto_restart/restart
if [ $should_restart == "0" ]
then
break
fi
echo 'If you want to stop the server completely, press STRG-C, \before the countdown is at 1!'
echo "Rebooting in:"
for i in 5 4 3 2 1
do
echo "$i..."
sleep 1
done
echo 'Server restarts!'
done
Thanks for the logo to Muse31.
You can use this mod in non-commercial modpacks without asking.
You can find more mods from me here.
Hi, I made a BetterMinecraft server and their modpack server doesn't have a jar but a powershell command, how would I go about setting up the script to auto restart ? Thank you in advance. I try using some modification that the discord member have shown but the autorestart just stop the server and not restarting it. the autorestart folder with the restart is marked as 1 after the autorestart stop the server but it never actually attempt to restart the server...
Ive tried lots of iterations on my oracle hosted server. Ive installed screen, running on Linux. The restart command is recognised, but whether i use external file or command it fails both ways.
Im connected by ssh, the putty window is called "opc@minecraft-server"
[10:48:29] [Server thread/INFO] [de.ge.au.ut.ServerRestarter/]: Restart Server
[10:48:29] [Server thread/ERROR] [de.ge.au.ut.ServerRestarter/]: Auto Restart could not be done.
java.io.IOException: Cannot run program "bash -c 'cd /home/opc/; screen -d -m -S opc@minecraft-server java -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=32M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs/ -Daikars.new.flags=true -jar forge-wrapper.jar -nogui'": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) ~[?:?] {}
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?] {}
at de.geheimagentnr1.auto_restart.util.ServerRestarter.restartServer(ServerRestarter.java:34) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading}
at de.geheimagentnr1.auto_restart.handlers.ForgeEventHandler.handleServerStoppedEvent(ForgeEventHandler.java:65) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading}
at de.geheimagentnr1.auto_restart.handlers.__ForgeEventHandler_handleServerStoppedEvent_ServerStoppedEvent.invoke(.dynamic) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading,pl:eventbus:B}
at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.server.ServerLifecycleHooks.handleServerStopped(ServerLifecycleHooks.java:127) ~[forge-1.19.2-43.2.3-universal.jar%23730!/:?] {re:classloading}
at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:690) ~[server-1.19.2-20220805.130853-srg.jar%23725!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:MinecraftServerMixin,pl:mixin:APP:kubejs-common.mixins.json:inject_resources.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:ae2.mixins.json:spatial.MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:access.MinecraftServerAccess,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:elementalcraft.mixins.json:MixinMinecraftServer,pl:mixin:A}
at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:244) ~[server-1.19.2-20220805.130853-srg.jar%23725!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:MinecraftServerMixin,pl:mixin:APP:kubejs-common.mixins.json:inject_resources.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:ae2.mixins.json:spatial.MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:access.MinecraftServerAccess,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:elementalcraft.mixins.json:MixinMinecraftServer,pl:mixin:A}
at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin}
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.ProcessImpl.forkAndExec(Native Method) ~[?:?] {}
at java.lang.ProcessImpl.<init>(ProcessImpl.java:314) ~[?:?] {}
at java.lang.ProcessImpl.start(ProcessImpl.java:244) ~[?:?] {}
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1110) ~[?:?] {}
... 11 more
In reply to FeniksTV:
Tested also calling directly from the jar folder using the unix_args.text - same error.
[10:52:10] [Server thread/INFO] [de.ge.au.ut.ServerRestarter/]: Restart Server
[10:52:10] [Server thread/ERROR] [de.ge.au.ut.ServerRestarter/]: Auto Restart could not be done.
java.io.IOException: Cannot run program "bash -c 'cd /home/opc/; screen -d -m -S opc@minecraft-server java -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=32M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs/ -Daikars.new.flags=true @libraries/net/minecraftforge/forge/1.19.2-43.2.3/unix_args.txt'": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) ~[?:?] {}
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?] {}
at de.geheimagentnr1.auto_restart.util.ServerRestarter.restartServer(ServerRestarter.java:34) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading}
at de.geheimagentnr1.auto_restart.handlers.ForgeEventHandler.handleServerStoppedEvent(ForgeEventHandler.java:65) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading}
at de.geheimagentnr1.auto_restart.handlers.__ForgeEventHandler_handleServerStoppedEvent_ServerStoppedEvent.invoke(.dynamic) ~[AutoRestart-1.19.2-2.0.1.jar%23449!/:2.0.1] {re:classloading,pl:eventbus:B}
at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.3.jar%2351!/:?] {}
at net.minecraftforge.server.ServerLifecycleHooks.handleServerStopped(ServerLifecycleHooks.java:127) ~[forge-1.19.2-43.2.3-universal.jar%23730!/:?] {re:classloading}
at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:690) ~[server-1.19.2-20220805.130853-srg.jar%23725!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:MinecraftServerMixin,pl:mixin:APP:kubejs-common.mixins.json:inject_resources.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:ae2.mixins.json:spatial.MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:access.MinecraftServerAccess,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:elementalcraft.mixins.json:MixinMinecraftServer,pl:mixin:A}
at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:244) ~[server-1.19.2-20220805.130853-srg.jar%23725!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:MinecraftServerMixin,pl:mixin:APP:kubejs-common.mixins.json:inject_resources.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:ae2.mixins.json:spatial.MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:access.MinecraftServerAccess,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:elementalcraft.mixins.json:MixinMinecraftServer,pl:mixin:A}
at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin}
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.ProcessImpl.forkAndExec(Native Method) ~[?:?] {}
at java.lang.ProcessImpl.<init>(ProcessImpl.java:314) ~[?:?] {}
at java.lang.ProcessImpl.start(ProcessImpl.java:244) ~[?:?] {}
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1110) ~[?:?] {}
... 11 more
In reply to FeniksTV:
Running the command directly in console however, it works absolutely fine:
[opc@minecraft-server ~]$ java -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=32M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs/ -Daikars.new.flags=true @libraries/net/minecraftforge/forge/1.19.2-43.2.3/unix_args.txt
[10:53:20] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 43.2.3, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853]
[10:53:20] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.5 by Oracle Corporation; OS Linux arch aarch64 version 5.4.17-2136.314.6.2.el7uek.aarch64
[10:53:22] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/home/opc/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2363!/ Service=ModLauncher Env=SERVER
[10:53:23] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file /home/opc/libraries/net/minecraftforge/fmlcore/1.19.2-43.2.3/fmlcore-1.19.2-43.2.3.jar is missing mods.toml file
[10:53:23] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file /home/opc/libraries/net/minecraftforge/javafmllanguage/1.19.2-43.2.3/javafmllanguage-1.19.2-43.2.3.jar is missing mods.toml file
[10:53:23] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file /home/opc/libraries/net/minecraftforge/lowcodelanguage/1.19.2-43.2.3/lowcodelanguage-1.19.2-43.2.3.jar is missing mods.toml file
[10:53:23] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file /home/opc/libraries/net/minecraftforge/mclanguage/1.19.2-43.2.3/mclanguage-1.19.2-43.2.3.jar is missing mods.toml file
[10:53:23] [main/WARN] [ne.mi.ja.se.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: resourcefullib. Using Mod File: /home/opc/mods/resourcefullib-forge-1.19.2-1.1.19.jar
[10:53:23] [main/WARN] [ne.mi.ja.se.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: botarium. Using Mod File: /home/opc/mods/botarium-forge-1.19.2-1.8.2.jar
[10:53:23] [main/INFO] [ne.mi.fm.lo.mo.JarInJarDependencyLocator/]: Found 19 dependencies adding them to mods collection
I've tried to follow the instructions to as closely as I can, but to no avail, I am unable to successfully perform the /restart command in the command prompt, it'll save everything, but it'll always close and then not start up again. I'm unsure what I'm doing wrong. If it helps at all, I have been able to run the server and play on it before adding this mod.
In reply to JubbyDubbyTheSecond:
Did you start the Minecraft server by double-clicking the "restart_start.cmd" or the "run.bat"?
You have to start the Minecraft server by double-clicking the "restart_start.cmd".
In reply to GeheimagentNr1:
I started the server only using the "run.bat" file, after using the "restart_start.cmd" file, it runs great! Thanks a ton for the help! Wishing you and your family a Merry Christmas, and a Happy New Years. 😃
Is there a Fabric variant of this anywhere ?
can yout put on this page somewhere near the top that this is a forge mod? been trying to make it work on fabric this whole time cause i had no idea it was for forge. had to go to github to find out.
In reply to TwoPointInfinity:
How about the image with the hint, that the mod is a "Forge" mod directly above the place, where you write the comment, so you see it, if you write a comment?
In reply to GeheimagentNr1:
downside to it being an image is that the text search engines wont help with it. When i search for fabric restart mod or fabric stop mod of that nature it doesnt see the image text. People will still be brought here even when searching for fabric. I also did ctrl+F to search the page for fabric and didnt find anything so. Sorry i missed it, the page has much information.
When and how is the config file generated? I have the start and loop scripts created based on https://github.com/GeheimagentNr1/AutoRestart/wiki/Simple-Instructions:-1.3-Setup-(MC-1.17.1-or-newer,-Windows,-Start-Script), the mod is in the mod folder, and I've stopped and restarted the server several times since adding the mod. I can't get the server to start after issuing the /restart command and I'm pretty sure it's because there isn't a config file present.
EDIT: I'm using a 1.18.2 server. Issue is resolved. The config file didn't generate at ./world/serverconfig. It was generated at ./Home/serverconfig due to me starting a new world recently. If you are using a world name other than the default "world", you'll need to find the folder named for the new world to get the config file. As soon as I was able to set the restart script path in the config file, the mod works as expected.
hi im running a server using mobax and i followed the github guide but when i run the restart command it stops the server but doesnt restart it
In reply to spookanator1:
What scripts are you using and what does your configuration looks like?
How would I do this if I'm using oracle cloud hosting to host the server before I even run the server I have to ssh in. I'm running the server on a screen and I'm just confused. the way I shut down my server is by pressing ctrl-c and to start it up I use I do ./run.sh but to even run the server I need to login into the screen then cd into the folder and then run ./run.sh I'm just confused about how I can do that.
In reply to mr_kthulhu:
If you are OP on a Minecraft server, you can stop the server with the "/stop" command.
Starting the server will work with this mod too, only by running a sh file.
You can use this step-by-step introduction to set up the mod correctly: https://github.com/GeheimagentNr1/AutoRestart/wiki/Simple-Instructions
As operating system, you would choose Linux.
After restarting the server, the previous server command window will still be running. This will then build up several server command windows overtime, crashing the PC. Starting with double click does not solve the issue
In reply to CrazyPigCarrots:
Strange. Maybe there is another mod, that is preventing the server from stopping. Which mods do you have installed?
In reply to GeheimagentNr1:
I have around 30
but the mods "Supplementaries" and "Farmer's Delight" are the ones usually popping up with stuff after the restart
How do i make a script for my restart. i have everything setup in the config my times and warnings but when the server shuts down for a restart it doesn't restart. how do i make it start back up again. also running on 1.16.5 using the normal run.bat to start server.