Skip to content

Instantly share code, notes, and snippets.

@danmilleruk
Created November 30, 2011 15:54
Show Gist options
  • Save danmilleruk/1409580 to your computer and use it in GitHub Desktop.
Save danmilleruk/1409580 to your computer and use it in GitHub Desktop.
Minecraft Auto Restart Script
@ECHO OFF
CLS
ECHO The server started: %time:~0,5% %date:~1%
:SERVERLOOP
SET BINDIR=%~dp0
CD /D "%BINDIR%"
"%ProgramFiles(x86)%\Java\jre6\bin\java.exe" -Xincgc -Xmx1G -jar C:\games\minecraft\minecraft_server.jar nogui
ECHO Server crashes and restarted %time:~0,5% %date:~1%
ECHO.
GOTO SERVERLOOP
:END
@P3rf3ctXZer0
Copy link

Better version

@echo off
:start
SETLOCAL
for %%f in (forge*.jar) do (SET forge=%%~nxf)
java -Xms4g -Xmx8g -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -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 -Dfml.queryResult=confirm -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar %forge% nogui
ENDLOCAL
choice /c:RX /n /m "You have 5 seconds to restart the server - Press R to load now, or X to cancel. " /t:5 /d:x
IF %errorlevel%==1 goto start
echo Startup canceled.
pause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment