I have an openSUSE Leap 42.3 and I try to run a systemd service via udev in order to automate my backups. I use a simple systemd service that starts the backup script which works just fine from the CLI. Using udev, the systemd service is not started (error code 5). It turns out that the problem is not from the service, but from systemd!
Specifically, when I start the service without absolute paths from the CLI everything is fine:
# systemctl start hdd-backup.service # systemctl status hdd-backup.service ● hdd-backup.service - Backup to external HDD Loaded: loaded (/etc/systemd/system/hdd-backup.service; static; vendor preset: disabled) Active: active (running) since Tue 2018-04-10 21:09:34 EEST; 8s ago Main PID: 14455 (backup.sh) Tasks: 3 (limit: 512) CGroup: /system.slice/hdd-backup.service ├─14455 /bin/bash /usr/local/bin/backup.sh ├─14460 /sbin/mount.ntfs /dev/sdc1 /mnt/backup -o rw └─14463 sleep 3000
However, when I start the service with absolute paths is fails because it tries to start the .mount(!!!) service:
systemctl start /etc/systemd/system/hdd-backup.service Failed to start etc-systemd-system-hdd\x2dbackup.service.mount: Unit etc-systemd-system-hdd\x2dbackup.service.mount failed to load: No such file or directory.