I made a systemd service that launches a simple .sh to read data from a serial connection. If I run the service manually after booting it works fine, but when I try to run it automatically at boot it fails because the .sh can't yet read from ttyUSB0 (awk: fatal: cannot open file /dev/ttyUSB0' for reading (No such file or directory
).
Is there any way to make the service wait for ttyUSB0 and then run the .sh? I tried something like after=ttyUSB0 but that doesn't work.
[Unit]
Description=Serial logger
[Service]
ExecStart=/serial_script.sh
[Install]
WantedBy=default.target