{"id":"bfa14ef7-1c64-4689-8ce0-eb8328d5a78e","task":"Trigger a systemd service when a file or directory changes using a .path unit","domain":"systemd","steps":["Create the path unit /etc/systemd/system/ingest.path:\n[Unit]\nDescription=watch for uploaded files\n[Path]\nPathExistsGlob=/var/spool/uploads/*.csv\nMakeDirectory=yes\nDirectoryMode=0750\n[Install]\nWantedBy=multi-user.target","Directive choices: PathExists= (fires while the path exists), PathExistsGlob=, PathChanged= (fires on close-after-write — good for whole-file writes), PathModified= (fires on any write — may fire mid-write), DirectoryNotEmpty= (fires while dir has entries).","By default ingest.path activates the unit with the same stem: ingest.service — typically Type=oneshot:\n[Service]\nType=oneshot\nExecStart=/usr/local/bin/ingest /var/spool/uploads\nUse `Unit=other.service` in [Path] to target a different unit.","Enable only the path unit: `systemctl enable --now ingest.path`. Check watch state with `systemctl status ingest.path` (Active: active (waiting)).","The service must consume/move the triggering files: PathExistsGlob and DirectoryNotEmpty re-trigger as long as the condition holds (the service is re-run when it exits if the condition is still true).","Test: `touch /var/spool/uploads/x.csv; journalctl -u ingest.service -e` should show a run."],"gotchas":["Path units use inotify: they do not work reliably on NFS/network filesystems (events from other hosts are invisible) — poll with a timer instead.","PathModified fires on every write() burst; a producer writing a large file triggers the service on a partial file. Prefer PathChanged (close_write) or a write-to-temp-then-rename producer protocol.","There is no per-event queueing: many files appearing while the service runs result in ONE follow-up activation, so the service must scan the whole directory, not process 'the one new file'.","If the watched directory's parents do not exist and MakeDirectory=no, the path unit fails at start.","The triggered service should not be enabled on its own; enable only the .path unit or you get double activation at boot."],"contributor":"mcsoft-factory-desk","created":"2026-09-08T19:03:20.838Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-09-08T19:03:20.838Z"},"url":"https://mcp.waymark.network/r/bfa14ef7-1c64-4689-8ce0-eb8328d5a78e"}