systemd start /etc/systemd/system/custom.service no puede iniciarse

systemd start /etc/systemd/system/custom.service no puede iniciarse

Tengo un openSUSE Leap 42.3 e intento ejecutar un servicio systemd a través de udev para automatizar mis copias de seguridad. Utilizo un servicio systemd simple que inicia el script de respaldo que funciona bien desde la CLI. Al utilizar udev, el servicio systemd no se inicia (código de error 5). ¡Resulta que el problema no es del servicio, sino de systemd!

Específicamente, cuando inicio el servicio sin rutas absolutas desde la CLI, todo está bien:

# 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

Sin embargo, cuando inicio el servicio conabsolutopaths falla porque intenta iniciar el servicio .mount(!!!):

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.

¿Alguna idea?

Respuesta1

Eso es normal. sistemadno soportainiciar unidades desde ubicaciones arbitrarias; deben estar en uno de los directorios de búsqueda estándar. Si su unidad ya está en /etc/systemd/system, nunca es necesario especificar su ruta.


systemctl tiene varios atajos para iniciar diferentes tipos de unidades: las rutas de directorio se traducen a unidades .mount; por ejemplo, systemctl start /mnt/datase traduce a systemctl start mnt-data.mount.

información relacionada