I want to start a service with a screen
command in detached more. The backgound is, that it shall read a serial interface and with reconnecting to the screen I want to be able to interact in case of errors or so to send commands via the serial interface.
Currently I have
systemd service file
[Unit]
Description=read serial interface
[Service]
User=someUser
Group=someUser
Type=forking
Restart=on-failure
RestartSec=3
WorkingDirectory=/home/someUser/dev
ExecStart=/usr/bin/screen -DmS serial-magic /home/someUser/dev/run-serial-magic.sh
[Install]
WantedBy=multi-user.target
Script under /home/someUser/dev/run-serial-magic.sh
#!/bin/bash
pio device monitor -b 115200 -p /dev/ttyUSB0 | tee test.log
I already tried
- moving the
screen
inside the script. - using
Type=simple
with screen option-d
instead of-D
The script is working if I call it manually from the command line. I can return to the screen and detach it again.
But when I start the service sudo journalctl -f -u someServoce.service
just gives me
Okt 23 18:13:28 someHost systemd[1]: Starting read serial interface...
But screen -list
says
No Sockets found in /run/screen/S-someUser.
/usr/bin/screen -dmS
, see: superuser.com/a/1276822/645522. Silly question, but are you logging as someUser to check that your service is running ? You will only see screen sessions that belong to you.