So I have a server that I can run from a bash terminal using e.g.

java -jar spigot.jar

which will send output to stdout (I believe), and thus be printed to the terminal screen. To stop the server from the terminal, one simply sends the "stop" command to the server, at which point the server initiates shutdown (saves current data, etc.).

However, I don't want to have to start the server every time I reboot, or have an extra bash terminal hanging around with the open process, so I've been trying to set up a systemd service to run the server automatically, and take standard input from (anywhere, really), using a .service file like the following:

Description=Spigot Minecraft server daemon

WorkingDirectory=*location where spigot.jar is*


ExecStart=/usr/bin/java -jar spigot.jar
ExecStop=/bin/sh -c 'echo stop >/dev/tty2'


But I can't figure out why this won't work. What I thought it should do is pipe /dev/tty2 to the server, and when I use the command

systemctl stop *service*

it should send "stop" (indirectly through /dev/tty2) to the server. What am I missing?

But the service doesn't seem to run? If I comment out the StandardInput & TTYPath lines, the server starts, but when issuing

systemctl stop *service*

and then reviewing server logs through

journalctl -u *service*

the proper shutdown sequence never initiated -- the process was just killed (instead of gracefully stopping itself).

So what I want to know is: how do I run this server as a service, with some FIFO/file/tty/something piped into it (so I can still issue server commands)?

1 Answer 1


I'm guessing you are trying too hard. The standard way to shutdown a service is send it a SIGTERM signal (polite) or a SIGKILL signal (forceful). I believe that's the default systemd behavior. So try removing all these lines from your systemd unit file:

ExecStop=/bin/sh -c 'echo stop >/dev/tty2'

There are plenty or references on the Spogit site to using SIGTERM and SIGKILL

  • That might be true for the particular case of spigot, but the OP question about how to pipe to a daemon remains unanswered.
    – MestreLion
    Commented Sep 29, 2020 at 20:53
  • You don't. You communicate with a daemon via signals, sockets, ports, IPC or some other mechanism. Commented Oct 13, 2020 at 15:06
  • Too bad the official Minecraft server (not spigot) does not handle signals in a standard way :-(. There's no signal to gracefully stop it and make it save all world data before exiting. SIGTERM (and all the others I tried) simply shut it down.
    – MestreLion
    Commented Oct 27, 2020 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .