You beat me to it this morning ! yes, I have and it’s the closest I have gotten to make this work. In essence it “should” work.
From the man pages :
SYNOPSIS top
path.path
DESCRIPTION top
A unit configuration file whose name ends in ".path" encodes
information about a path monitored by systemd, for path-based
activation.
This man page lists the configuration options specific to this
unit type. See systemd.unit(5) for the common options of all unit
configuration files. The common configuration items are
configured in the generic [Unit] and [Install] sections. The path
specific configuration options are configured in the [Path]
section.
For each path file, a matching unit file must exist, describing
the unit to activate when the path changes. By default, a service
by the same name as the path (except for the suffix) is
activated. Example: a path file foo.path activates a matching
service foo.service. The unit to activate may be controlled by
Unit= (see below).
Internally, path units use the inotify(7) API to monitor file
systems. Due to that, it suffers by the same limitations as
inotify, and for example cannot be used to monitor files or
directories changed by other machines on remote NFS file systems.
When a service unit triggered by a path unit terminates
(regardless whether it exited successfully or failed), monitored
paths are checked immediately again, and the service accordingly
restarted instantly. As protection against busy looping in this
trigger/start cycle, a start rate limit is enforced on the
service unit, see StartLimitIntervalSec= and StartLimitBurst= in
systemd.unit(5). Unlike other service failures, the error
condition that the start rate limit is hit is propagated from the
service unit to the path unit and causes the path unit to fail as
well, thus ending the loop.
So the key point here is :
- “Internally, path units use the inotify(7) API to monitor file systems.”
- “When a service unit triggered by a path unit terminates (regardless whether it exited successfully or failed), monitored paths are checked immediately again, and the service accordingly restarted instantly.”
So my .path file should work :
[Unit]
Description=EasyStore Mount
[Path]
PathExists=/run/media/my-user/5003a2b4-88c9-4e8a-acef-df00707c50f3
[Install]
WantedBy=default.target
Buuuut. . . It doesn’t or should I say it tries too much ! i get a lot of errors for :
XFS (dm-3): Mounting V5 Filesystem 5003a2b4-88c9-4e8a-acef-df00707c50f3
Jun 12 23:55:41 (ackup.sh)[7486]: EasyStore_Rsync_Backup.service: Failed to determine supplementary groups: Operation not permitted
Jun 12 23:55:41 systemd[4249]: Starting EasyStore_Rsync_Backup.service - Backup script after USB mount...
Jun 12 23:55:41 systemd[4249]: EasyStore_Rsync_Backup.service: Main process exited, code=exited, status=216/GROUP
Jun 12 23:55:41 systemd[4249]: EasyStore_Rsync_Backup.service: Failed with result 'exit-code'.
Jun 12 23:55:41 systemd[4249]: Failed to start EasyStore_Rsync_Backup.service - Backup script after USB mount.
Jun 12 23:55:41 systemd[4249]: Starting EasyStore_Rsync_Backup.service - Backup script after USB mount...
Also :
Jun 12 23:00:07 systemd[4273]: Failed to start EasyStore_Rsync_Backup.service - Backup script after USB mount.
Jun 12 23:00:07 systemd[4273]: EasyStore_Rsync_Backup.service: Start request repeated too quickly.
Jun 12 23:00:07 systemd[4273]: EasyStore_Rsync_Backup.service: Failed with result 'exit-code'.
Jun 12 23:00:07 systemd[4273]: Failed to start EasyStore_Rsync_Backup.service - Backup script after USB mount.
Jun 12 23:00:07 systemd[4273]: EasyStore_Rsync_Backup.path: Failed with result 'unit-start-limit-hit'.
The latter I tried to fix with 2 directives called :
TriggerLimitIntervalSec=, TriggerLimitBurst=
So here I am. . . I’ll keep posting with more info as I get it, hopefully working.