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.

Any idea?

  • 1
    Please update the question to include the contents of /etc/systemd/system/hdd-backup.service – Mark Stosberg Apr 10 '18 at 19:00

That's normal. Systemd does not support starting units from arbitrary locations; they must be in one of the standard searched directories. If your unit is already in /etc/systemd/system, there is never any need to specify its path.

systemctl has various shortcuts for starting different unit types – directory paths are translated to .mount units; e.g. systemctl start /mnt/data is translated to systemctl start mnt-data.mount.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.