MC server startup script writing


A record of the startup script of the Minecraft server.

First, each server will have a jar file used to start the server. This is modified according to the specific situation. Here, forge directly starts the server as an example, and the file forge-1.12.2-14.23.5.2854.jar is used to start the server.
The minimum memory of the server is set to 1024M, and the maximum memory is set to 4096M. At the same time, there is no need for a graphical interface and the configuration parameter nogui.
The core startup command is:

java -server -XX:+UseG1GC  -Xmx6144M -Xms1024M -jar forge-1.12.2-14.23.5.2854.jar nogui

Then randomly add some optimization parameters (not necessarily positive optimization, adjust according to the specific situation)

java -server -XX:+UseG1GC  -Xms1024M -Xmx4096M -jar forge-1.12.2-14.23.5.2854.jar nogui -noverify -XX:+AggressiveOpts -XX:+UseCompressedOops

After completing the core startup statement, it is necessary to write the startup script according to the specific operating system.

1. .sh startup script for Linux system

Create any file with the suffix .sh and use chmod +x to add running permissions.
When running, use ./filename.sh to run the file.

1.1 Linux single boot

#!/bin/sh

java -server -XX:+UseG1GC  -Xms1024M -Xmx4096M -jar forge-1.12.2-14.23.5.2854.jar nogui -noverify -XX:+AggressiveOpts -XX:+UseCompressedOops

1.2 Linux starts ten times in a loop

After the server crashes, it will automatically restart, a total of ten times, to deal with those small crash bugs that are not starting the infinite loop of seconds.

#!/bin/sh

for ((i=0; i<10; i ++))
do
	java -server -XX:+UseG1GC  -Xms1024M -Xmx4096M -jar forge-1.12.2-14.23.5.2854.jar nogui -noverify -XX:+AggressiveOpts -XX:+UseCompressedOops
done

1.3 Linux infinite loop startup

After the crash, the infinite loop starts, which can only be stopped by forcibly terminating the screen or restarting the computer.

#!/bin/sh

while ((1))
do
	java -server -XX:+UseG1GC  -Xms1024M -Xmx4096M -jar forge-1.12.2-14.23.5.2854.jar nogui -noverify -XX:+AggressiveOpts -XX:+UseCompressedOops
done

2. .bat startup script for Windows system

Create a new file with a .bat extension, and double-click to run the file when it is running.
Note: If you want to use Chinese in the cmd of the windows system, you need to write the .bat file with GB2312 encoding, otherwise the Chinese will have garbled characters.
Single-start .bat script writing:

@ECHO OFF
title Minecraft Server
java -server -XX:+UseG1GC  -Xms1024M -Xmx4096M -jar forge-1.12.2-14.23.5.2854.jar nogui -noverify -XX:+AggressiveOpts -XX:+UseCompressedOops
pause
EXIT

Guess you like

Origin blog.csdn.net/starvapour/article/details/113415562