1

I'm running a Minecraft server as a systemd service. The service's ExecStart is the path to a script whose contents are:

screen -L -DmS minecraft java -Xmx4096M -Xms1024M -jar server.jar nogui

That is, this is running as a simple service, not forked.

I would like for the output of the java call to be logged via systemd's usual mechanism, in addition to being visible in the screen session. I am almost a total novice when it comes to systemd, so I'm not sure where to start with that. Can I tee the output of the java call into something?

Thom Smith
  • 269
  • 2
  • 5
  • 2
    why you want to run with `screen`? normally without `screen` the process log should go to `journal` log. anyway please provide the content of the service file and you can try adding `StandardOutput=journal` and `StandardError=journal` explicitly in service unit. – binarysta Sep 30 '20 at 11:20
  • 2
    The minecraft executable has an interactive shell that the admin needs to be able to access. The simplest way to do this is to run it in a screen session. However, in the end I decided to abandon screen and rely entirely on minecraft's rcon functionality to send commands. This made capturing standard output trivial. I'm not sure whether this would answer the question as it was asked. – Thom Smith Sep 30 '20 at 15:08
  • There are many reasons why you would want a process to run in a screen session. Even though OP used minecrafts rcon instead of its interactive shell, I would still like to know the answer to OPs initial question. – birgersp Aug 16 '21 at 12:46

1 Answers1

1

I eventually solved this problem by changing the way I ran the server. I stopped using screen entirely and used Minecraft's RCON support to control the server (e.g. stopping it). I'm not sure it's precisely an answer this question as I've asked it, but it should work well for anyone specifically running a Minecraft server.

Full details here: Minecraft server startup/shutdown with systemd.

Thom Smith
  • 269
  • 2
  • 5