Stop Polling Drop Directories: Practical systemd.path Units on Linux
You have a drop directory. A scanner dumps PDFs into /var/spool/inbox, a camera drops JPEGs into /var/lib/captures, a CI agent writes a flag file when a build is ready. The usual “solution” is a shell loop: while true; do find /var/spool/inbox -type f -print0 | xargs -0 -r process-one sleep 5 done That works until it does not. You burn wakeups when the directory is empty, miss batches that land between polls, race with partial writes, and end up reinventing supervision, logging, and restart policy around a sleep. systemd already has a unit type for this: .path units.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in