0

so I made this .service in /etc/systemd/system to run a script when a Thumb Drive is mounted, here is the code:

#!/bin/bash

[Unit] Description=My Flash Backup script trigger After=media-Drive.mount

[Service] Type=notify ExecStart=/bin/bash /home/user/Documents/Backup.sh

[Install] WantedBy=multi-user.target

The problem is that it gives a failed (Result: protocol) this means that I need to restart the daemon every time I want to mount the thumb drive, which just makes manually launching it from a terminal alias much easier... how to make it so that I don't need to reload?

Also, when I try to systemctl start Backup.service it gives

Job for Backup.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status Backup.service" and "journalctl -xeu Backup.service" for details.

and with systemctl status Backup.service

Aug 11 20:38:22 creator-5 systemd[1]: Backup.service: Failed with result 'protocol'.
Aug 11 20:38:22 creator-5 systemd[1]: Failed to start Backup.service - My Flash Backup script trigger.

What did I understand or done wrong?

edit1: if it matters, the script is executable, and it's a rsync command

Edit2: now it works fine, now I must make it so that it works every time the drive is mounted and not only the first time in each login session.

The service now looks like this:

[Unit]
Description=My Flash Backup script trigger
After=media-Drive.mount

[Service] Type=oneshot ExecStart=/bin/bash /home/user/Documents/Backup.sh

[Install] WantedBy=multi-user.target

Edit3: also, if possible, i'd like to make it run every 10 mins the drive is mounted...

0 Answers0