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
screeninside the script.
Type=simplewith screen option
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: Starting read serial interface...
screen -list says
No Sockets found in /run/screen/S-someUser.