So on CentOS you have to drop the ProtectHome, ProtectSystem and PrivateDevices otherwise you will probably get warnings in the log because those options were introduced in Systemd v214.
Note on CentOSĪs CentOS has a quite old systemd Version there are some features missing.
#Minecraft server properties how to#
The Install section specifies how to enable this service so that it is started every boot.Ĭreate the file in the directory /etc/systemd/system/rvice and paste the contents from above. you have to replace $port and $password with the actual values you specify in the server.properties file of the minecraft server. If you want to pass more advanced options to the server then this is most probably the place to do so.ĮxecStop specifies the command that is issued to stop the server. So if the server should be compromised in any way it should not be able to acess anything outside the /var/minecraft/server directory.ĮxecStart specifies the command that fires up the server. The following lines regulate the access of the server. The next line marks the service as sucessfully exited. Line 13 and 14 are more important again KillMode=none says that the server is not killed when the service is stoped but instead the ExecStop command is used to gracefully stop the server. I thought it might be usefull but actually I didn't use it. With line 12 I import a nf file that can be used to set various environment variables. I do that because my server hosts other services besides the minecraftserver that are more important to me.
lines 9, 10 and 11 restrict the minecraft server so that it is run as minecraft user and group with a nice level of 5 meaning that it has a lower priority than most other things that run on the server. The Service section is the one that gets more interesting.
Line 5 and 6 say that this service likes to have network available.
#Minecraft server properties full#
Description = Minecraft Server Documentation = Wants = network.target After = network.target User = minecraft Group = minecraft Nice = 5 EnvironmentFile = -/var/minecraft/nf KillMode = none SuccessExitStatus = 0 1 ProtectHome = true ProtectSystem = full PrivateDevices = true NoNewPrivileges = true PrivateTmp = true InaccessibleDirectories = /root /sys /srv -/opt /media -/lost+found ReadWriteDirectories = /var/minecraft/server WorkingDirectory = /var/minecraft/server ExecStart = /usr/bin/java -Xmx1024M -Xms1024M -jar spigot.jar -noconsole ExecStop = /var/minecraft/mcrcon -H localhost -P $port -p $password stop WantedBy = multi-user.targetįirst the easy things: line 2 and 3 contain descriptive information you can fill in anything you like.