Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For launchd there is WatchPaths (and for some more specific case QueueDirectories) which monitors changes on a path. However, if it is a directory, it will only recognize creations/deletions in the directory, i.e. not changed content of the containing files or any changes in any subdirectories (see here).

(For Linux, some good solutions seem to be listed here.)

It seems like launchd is not able to do it, is it?

I could write my own always-running daemon which extends launchd by this functionality, via FSEvents (or kqueue, fam or gamin?).

Or are there existing projects/tools which can do that?

share|improve this question

launchd should also monitor for changes to files (directly) under directories in WatchPaths.

Try saving this plist as ~/Library/LaunchAgents/test.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Then run launchctl load ~/Library/LaunchAgents/test.plist and modify some file under ~/Documents/. The program should be run even if you modify the file without performing an atomic save or even if the modification time of ~/Documents/ is not changed.

Note that launchd does not monitor for changes in subdirectories of the watched directories. Tilde expansion works in the arguments for WatchPaths by default, but there is no way to enable filename expansion. (EnableGlobbing only applies to ProgramArguments.)

share|improve this answer
According to my link, it does not. But even if it does, it is still not useful for me because I want a solution which monitors all of the content, i.e. also subdirectories. – Albert Oct 9 '13 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .