Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@HorlogeSkynet
Last active July 2, 2022 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HorlogeSkynet/05186008419422836b7615835cbb0eb3 to your computer and use it in GitHub Desktop.
Save HorlogeSkynet/05186008419422836b7615835cbb0eb3 to your computer and use it in GitHub Desktop.
systemd unit file for Minecraft server running against OpenJDK 11
[Unit]
Description=Minecraft Server
Wants=network.target
After=network.target
[Service]
User=minecraft
Nice=5
Restart=on-failure
SuccessExitStatus=0 143
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessiblePaths=/root /run/user /sys /srv /opt /media -/lost+found
ReadWritePaths=/home/minecraft
WorkingDirectory=/home/minecraft
ExecStart=/usr/bin/java -Xms1024M -Xmx2048M -jar server.jar --nogui
# mcrcon (>= v0.7.1) should be manually installed from <https://github.com/Tiiffi/mcrcon>.
ExecStop=/usr/local/bin/mcrcon \
-s \
-w 5 \
-H 127.0.0.1 -P 25575 \
-p 'YOUR_VERY_STRONG_RCON_PASSWORD' \
"say Server is about to restart. See you soon !" \
"stop"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment