lwc:programming:bash:systemd

  • create the config (?) for the service as /lib/systemd/system/<unit name>.service
    • is it actually supposed to go in /etc/systemd/system not /lib/systemd/system?
  • Inside the config:
  • enable the service: sudo systemctl enable application.service

Restart Always in service has limits. Kill 'em limits:

  • in [unit] add StartLimitIntervalSec=0 so systemd will continue to try to restart the service forever
  • in [Service] add RestartSec=1 to have systemd retry every second (instead of the default every 100ms)
  • plug in the usb device look up the vender id and product id of the USB device. lsusb or usbreset will both give you this information
  • create a file in /etc/udev/rules.d for example /etc/udev/rules.d/80-local.rules and put in it something like this example:
ACTION=="add", ATTR{idVendor}=="0582", ATTR{idProduct}=="01d6", TAG+="systemd", ENV{SYSTEMD_WANTS}="jackd.service"

source

Example

  • create /etc/udev/rules.d/20-usb-bus.rules with content: KERNEL=="usb[1-2]", TAG+="systemd"
  • reboot or udev rules reload and now voila: systemctl status dev-bus-usb-001-001.device
  • then in [Unit] you can do something like After=dev-bus-usb-001-001.device dev-bus-usb-002-001.device

source

  • lwc/programming/bash/systemd.txt
  • Last modified: 2023/10/06 15:03
  • by John Harrison