Systemd path units
These are the notes of a training course on systemd I gave as part of my work with Truelite.
This kind of unit can be used to monitor a file or directory for changes using inotify, and activate other units when an event happens.
For example, this activates a unit that manages a spool directory, which
activates another unit whenever a
[Unit] Description=Monitor /tmp/spool/ for new .pdf files [Path] Unit=beeponce.service PathExistsGlob=/tmp/spool/*.pdf MakeDirectory=true
This instead activates another unit whenever
/tmp/ready is changed, for
example by someone running
[Unit] Description=Monitor /tmp/ready [Path] Unit=beeponce.service PathChanged=/tmp/ready
[Unit] Description=Beeps once [Service] Type=oneshot ExecStart=/usr/bin/aplay /tmp/beep.wav