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
screen -list
say? As the service runs asroot
, maybe you have to run that asroot
. Or look for sockets in/var/run/screen
viasudo ls -lR /var/run/screen
.