1

I'm trying to figure out how to get my Minecraft server to start with my system. I'm currently on Ubuntu 21.04, kernel 5.11 and my DE is Gnome 3. I was following this post over on the Ubuntu StackExchange to setup a Minecraft service in systemd, after a lot of tinkering I was able to get it to start, but I get Java error's, and The server says I need to accept the eula even though I already have.

Here is what's in my /etc/systemd/system/minecraft.service file:

Description=Minecraft server
Wants=network.target
After=local-fs.target network.target

[Service]
User=minecraft
Group=minecraft
UMask=0027

EnvironmentFile=/etc/conf.d/minecraft
KillMode=none 
SuccessExitStatus=0 1 255

NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=full

ExecStart=/usr/bin/java -Xms2G -Xmx3G -jar /etc/conf.d/Minecraft/server.jar --nogui
# ExecStop=/usr/bin/mcrcon -H localhost -p ${RCON_PASSWD} stop

[Install]
WantedBy=multi-user.target

I know some stuff could be removed from it, like the EnvironmentFile since I'm not using it, but I haven't finished trimming this down yet.

Now here's what my terminal shows when I run sudo systemctl status minecraft.service:

     Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2021-05-12 21:25:55 EDT; 14min ago
    Process: 5036 ExecStart=/usr/bin/java -Xms2G -Xmx3G -jar /etc/conf.d/Minecraft/server.jar --nogui (code=exited, status=0/SUCCESS)
   Main PID: 5036 (code=exited, status=0/SUCCESS)

May 12 21:25:50 terrys-nas java[5036]:         at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
May 12 21:25:50 terrys-nas java[5036]:         at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
May 12 21:25:50 terrys-nas java[5036]:         at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
May 12 21:25:50 terrys-nas java[5036]:         at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:537)
May 12 21:25:50 terrys-nas java[5036]:         at net.minecraft.server.Main.<clinit>(SourceFile:57)
May 12 21:25:50 terrys-nas java[5036]: 2021-05-12 21:25:50,764 main ERROR Null object returned for RollingRandomAccessFile in Appenders.
May 12 21:25:50 terrys-nas java[5036]: 2021-05-12 21:25:50,773 main ERROR Unable to locate appender "File" for logger config "root"
May 12 21:25:55 terrys-nas java[5036]: [21:25:55] [main/ERROR]: Failed to store properties to file: server.properties
May 12 21:25:55 terrys-nas java[5036]: [21:25:55] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
May 12 21:25:55 terrys-nas systemd[1]: minecraft.service: Succeeded.

The version of Java that I'm using is openjdk version "1.8.0_292", and the server runs just fine if I start it manually.

I Did some more playing around, decided to clear out the entire Minecraft directory and just leave the server.jar in it hoping it would recreate the files for me then I could go in and edit them, it didn't. Just server.jar in the directory.

If you need any other information about my setup let me know, thanks for your time.

1
  • Yeah, I had done that and it didn't work nor make the message go away. Eitherway, I tried again, I did sudo nano eula.txt in the directory where the server.jar is, put eula=true and restarted the system, still didn't work. EDIT: Looks like the comment I was replying to is gone? I'm new to this site so I'm not sure how it all works.
    – Tesseeaye
    May 13, 2021 at 2:07

1 Answer 1

2
  1. Your output suggests that you didn't set up the EULA file. Run the server once to generate the file (you did that already).

    Then edit eula.txt so it says eula=true. Then the server will start.

  2. Most folks start the server inside a screen session. This allows you greater control.

    Here's my own minecraft.service file, showing how the server starts inside a screen session, and can also be safely stopped by calling the same session. Your WorkingDirectory and User and server memory settings will differ, of course.

[Unit]
Description=Minecraft Server
After=network.target

[Service]
RemainAfterExit=yes
WorkingDirectory=/home/minecraft
User=minecraft
# Start Screen, Java, and Minecraft
ExecStart=screen -s mc -d -m java -server -Xms512M -Xmx1024M -jar server.jar nogui
# Tell Minecraft to gracefully stop.
# Ending Minecraft will terminate Java
# systemd will kill Screen after the 10-second delay. No explicit kill for Screen needed
ExecStop=screen -p 0 -S mc -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\015'
ExecStop=screen -p 0 -S mc -X eval 'stuff "save-all"\015'
ExecStop=screen -p 0 -S mc -X eval 'stuff "stop"\015'
ExecStop=sleep 10

[Install]
WantedBy=multi-user.target
  1. BONUS #1: You can check that the server is running by looking at top. Java should be consuming resources. If not, then your server has crashed.

  2. BONUS #2: You can view the Minecraft Server's screen output in logs/latest.log That's an easy way to confirm that the server is indeed running, world has been successfully created, folks are able to join, etc.

2
  • Hey thank you so much! Your script worked perfectly. I think my main issue was permissions, but actually putting the server in the minecraft users home directory helped. I am running now. I do have one question though. How do I switch to that "screen" for management if I'm not logged into the game? This server is mostly for my GF sister and her bf to play on, I'm just hosting it haha.
    – Tesseeaye
    May 13, 2021 at 2:44
  • The easiest way to manage the server is from within the game. The purpose of screen to be able to stop the server safely by using systemd. There are whole tutorials on how to use screen correctly -- it's much too broad of a subject to answer here. Remember to back up the world regularly so anything they build isn't lost by a crash.
    – user535733
    May 13, 2021 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.