I've been trying to get a systemd service to work for a while now, but with no luck. What I am trying to do is create a startup script that will start a java program for a modded-Minecraft server.

Here is the systemd service file named ftbstart.service. It is placed in /etc/systemd/system/ and has permissions 744 (though I tested a variety of different permissions).

Description=FTB Server




So ExecStart starts another script with permissions 755 called sstart.sh which contains the lines:


echo I made it to 1
mount -t tmpfs -o size=1024M tmpfs /usr/games/ftb/current/
echo I made it to 2
cp -r /usr/games/ftb/beyond/. /usr/games/ftb/current/
echo I made it to 3
/usr/bin/screen -S ftb -d -m /usr/games/ftb/current/ServerStart.sh
echo I made it to 4

The echos are there for debugging purposes. The script runs all the way through, as

journalctl -u ftbstart

shows all echos from 1-4, however screen -list doesn't show any active screens after

systemctl restart ftbstart

However if I execute the script /usr/games/ftb/sstart.sh from the /bin/bash command line it runs perfectly fine and starts up no problem.

Things I've tried so far:

  • adding #!/bin/bash to top of ftbstart.service file
  • removing After=
  • changing/removing Type= (Type=simple and Type=forking)
  • changing/removing User= and Group=
  • changing file permissions on both ftbstart.service and sstart.sh
  • putting ExecStart=/bin/bash /usr/games/ftb/sstart.sh

I also make sure to type:

systemctl daemon-reload


systemctl restart ftbstart

each time I test something in the ftbstart.service file, etc etc and nothing seems to work.

I have also tried just adding the line

ExecStart=/usr/bin/screen -S ftb -d -m /usr/games/ftb/current/ServerStart.sh

to ftbstart.service but it still doesn't execute the screen service, but

systemctl status ftbstart

just shows something like:

Active: active (exited) since Thu 2017-09-07 20:56:35 UTC; 32min ago

However if I replace that ExecStart= in ftbstart.service with one such as:

ExecStart=screen -S top -d -m /usr/bin/top

then it DOES WORK magically! It creates a screen which can be attached to and shows the top command-line resource monitor.

So, sorry for the long question, but can anybody help me figure out what I am doing wrong? My guess is that because I am starting another script rather than a program that something is messing up somewhere, but I am not sure. Thank you for any assistance you may provide.

P.S. If it is necessary, here is the startup script that is started by sstart.sh. I did not create this, it is the provided script that came with the minecraft modpack: https://pastebin.com/muCy0xnh

  • Why are you copying files to a tmpfs? And screen is an interactive program that requires a terminal; you can't run it from systemd. – psusi Sep 8 '17 at 1:18
  • @psusi I am copying files to a tmpfs for the purpose of running the Minecraft world from a ramdisk, which is just a bit faster than running it directly from the HDD. Thank you for this response, I haven't found any information suggesting this in all my googling. Mind if I private message you to ask you for more information? I don't want to go off-topic in the post by asking more questions. – brdagr Sep 8 '17 at 1:50
  • Also, @psusi I have used a Systemd service file with ExecStart=screen -S top -d -m /usr/bin/top and have successfully run screen from Systemd, so I am not sure why you say it can't be done. – brdagr Sep 8 '17 at 1:52
  • Have you enabled the service (sudo systemctl enable ftbstart.service)? Beyond that, I would recommend that you break your issue into smaller, more discrete pieces that will make troubleshooting much easier. – richbl Sep 8 '17 at 4:42
  • 1
    The first thing to do is add 2>/tmp/foo.log after each of the commands run by your script and then check /tmp/foo.log for any error messages. Your echo statements don't tell you anything about whether the commands were run successfully. – terdon Sep 8 '17 at 8:36

Your Answer

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

Browse other questions tagged or ask your own question.