2

I created a simple script to run four other commands. I have it located at /usr/local/bin/lbrystartup.sh, and it contains the following:

#!/bin/bash

#Start web scripts

screen -dmS main /var/www/html/main.sh
screen -dmS loop2 /var/www/html/loop2.sh
screen -dmS blocks /var/www/html/blocks.sh
screen -dmS lbry /var/stratum/run.sh lbry

When I run this script, it works fine. I end up with four screen instances in the list, and they're all running as necessary.

Next, I created a service for systemd to run on startup.

coinscripts.service looks like this:

[Unit]

Description = Coinscripts daemon
After network.target = auditd.service

[Service]

type=Simple
ExecStart =/usr/local/bin/lbrystartup.sh

[Install]

WantedBy = multi-user.target

I've enabled the service, and it's successful in doing so. However, when I run the service with "sudo systemctl start coinscripts", the screen instances don't open. But, when I use systemctl status coinscripts, I get the following:

● coinscripts.service - Coinscripts daemon Loaded: loaded (/etc/systemd/system/coinscripts.service; enabled; vendor pres
Active: inactive (dead) since Fri 2017-06-30 21:59:10 PDT; 1min 3s ago Process: 1050 ExecStart=/usr/local/bin/lbrystartup.sh (code=exited, status=0/S Main PID: 1050 (code=exited, status=0/SUCCESS)

Jun 30 21:59:10 ubuntu systemd[1]: Started Coinscripts daemon.

Same happens when I restart the machine.

What am I doing wrong with the service script? I'm using Ubuntu 16.04

2
  • What does screen -listsay? As the service runs as root, maybe you have to run that as root. Or look for sockets in /var/run/screen via sudo ls -lR /var/run/screen.
    – ridgy
    Commented Jul 1, 2017 at 8:53
  • When running the service, screen -list says there are no running screens. Commented Jul 1, 2017 at 16:58

1 Answer 1

0

Are you still having this issue? This is more of a comment than an answer, but I apparently don't have enough points or whatever to comment...

I'm having a somewhat related issue on 18.04. Are you on 16.04?

I notice that you have an error in your After= section. should be:

After=network.target auditd.service

Not sure you really need the auditd.service there, but I think it should be ok. Also, you have:

type=Simple

which I believe needs to be:

Type=simple

The ExecStart line may also be having a problem with the equals sign (try deleting the preceding space), but I'm not sure how systemd handles the spaces, so that may be fine.

Lastly, I think you may want this to be Type=forking, since you are calling a child process in screen that will not exit upon completion.

Edit:

I also just realized that you're not using absolute paths in your script (i.e. /usr/bin/program instead of just program). Try that too.

I also would like to throw in a suggestion to use tmux instead of screen. In my experience screen is not very robust and often crashes, and tmux is a much better implementation of the same service. The commands are different though, so read up on those if you do decide to try it.

You must log in to answer this question.

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