Understanding path units
You can use a path unit to have systemd
monitor a certain file or directory to see when it changes. When systemd
detects that the file or directory has changed, it will activate the specified service. We'll use the Common Unix Printing System (CUPS) as an example.
In the /lib/systemd/system/cups.path
file, we see this:
[Unit] Description=CUPS Scheduler PartOf=cups.service [Path] PathExists=/var/cache/cups/org.cups.cupsd [Install] WantedBy=multi-user.target
The PathExists=
line tells systemd
to monitor a specific file for changes, which in this case is the /var/cache/cups/org.cups.cupsd
file. If systemd
detects any changes to this file, it will activate the printing service.