Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minecraft systemd unit file
[root@plex ~]# cat /etc/systemd/system/minecraft@.service
[Unit]
Description=Minecraft Server %i
[Service]
WorkingDirectory=/opt/minecraft-%i
User=mcserver
ExecStart=/usr/bin/screen -DmS mc-%i /bin/java -Xmx2048M -jar minecraft_server.jar nogui
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 2
[Install]
WantedBy=multi-user.target
#########
# HowTo
#########
#
# Create directory in /opt/minecraft-XX where XX is a name like 'survival'
# Add minecraft_server.jar into dir with other conf files for minecraft server
#
# Enable/Start systemd service
# systemctl enable minecraft@survival
# systemctl start minecraft@survival
#
# To run multiple servers simply create a new dir structure and enable/start it
# systemctl enable minecraft@creative
# systemctl start minecraft@creative
@Nirei

This comment has been minimized.

Copy link

@Nirei Nirei commented Dec 19, 2019

This is not working.

@nathanielc

This comment has been minimized.

Copy link
Owner Author

@nathanielc nathanielc commented Dec 19, 2019

@Nirei Hi, I haven't used this gist in a few years now. I created this instead https://github.com/nathanielc/minecraft-multi-server. It serves my needs better. It uses docker instead of screen to background and manage the minecraft server processes. Maybe it can be of use to you as well.

@Nirei

This comment has been minimized.

Copy link

@Nirei Nirei commented Dec 31, 2019

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.