I am trying to make systemd unit that starts a script inside GNU screen headlessly. I did base my work here on a couple of questions some had that were related. I also tested the ExecStart
line in a shell as the user it should start for, and it works.
Here is the redacted systemd unit file I created and placed in /usr/lib/systemd/system/devredacted.service
...
[Unit]
Description=redacted development site inside screen
After=network-online.target
[Service]
Type=forking
Restart=on-failure
RestartSec=3
User=dev
Group=dev
ExecStart=/usr/bin/screen -L -dmS redacted-dev /home/dev/run.sh
When this is started the process does not appear when I look for it using ps aux | grep screen
and when I check the status, I see this...
Oct 16 05:45:30 funbox systemd[1]: Starting devredacted.service - redacted development site inside screen...
Oct 16 05:45:30 funbox systemd[1]: Started devredacted.service - redacted development site inside screen.
Oct 16 05:45:30 funbox systemd[1]: devredacted.service: Deactivated successfully.
I tested this as the user this systemd unit user, which has an interactive shell, and the command executed by the unit file clearly works...
$ /usr/bin/screen -L -dmS redacted-dev /home/dev/run.sh
$ screen -ls
There is a screen on:
31790.redacted-dev (Detached)
1 Socket in /run/screen/S-dev.