Your Location is: Home > Linux

Screen as a service on systemd wont start

From: Tokyo View: 3970 TeeJay 

Question

I'm trying to run screen on a systemd service as startup, so i can check on it later if needed, on an interactive shell, but the session wont stay up, and apparently it doesn't even start.

This is my unit file.

Description=MyService
After=network.target

[Service]
type=forking
User=<myuser>
Group=<myuser>
WorkingDirectory=/home/myuser
ExecStart=/usr/bin/screen -L -d -m -S myservice /home/myuser/runmycommands.sh

[Install]
WantedBy=multi-user.target

This is my script

cd mysoftware
echo "This doesn't work" >> /home/myuser/log.log
./mysoftware

All I get is a dead screen:

        737.myservice   (02/23/2021 10:59:18 PM)        (Dead ???)

If i copy the ExecStart line and run it directly, it works.

[email protected]:~$ /usr/bin/screen -L -d -m -S myservice /home/myuser/runmycommands.sh
[email protected]:~$ screen -wipe
There is a screen on:
        1026.myservice  (02/23/2021 11:14:46 PM)        (Detached)

Any ideas?

Best answer