0

I need to monitor a directory for new files that are added (constantly: one or two every 5 seconds are added and deleted).

It would be nice to tail them constantly in terminal, but since this seems unlikely, it would be also good to append all of the tails to a file. That way when I stop my process I can review all of the files that were added and deleted (I need the contents not the filename).

A shell script will work as well as long as it will run on Mac OSX Lion.

Any help? I've tried multi-tail and tail -f (but these don't monitor the directory for new files).

4

3 回答 3

0

也许 xtail ?它可以在 osx 上使用 homebrew 或 macports 安装。

于 2012-06-06T15:07:47.530 回答
0

CoreServices 提供了监视目录更改的方法。

Apple 的 Carbon 文档非常好,但我似乎无法链接到特定功能。搜索FNSubscribeByPath

如果您确实需要查看添加的文件的内容,那么您可以编写一个使用 FNSubscribeByPath 的工具来告诉您目录何时更改以及更改了什么,然后tail -f是文件。

您可能应该有一些东西来跟踪已启动的“tail -f”实例,以便在删除文件时可以杀死它们。否则,您的进程表最终将填满。

于 2012-06-06T15:23:14.073 回答
0

您应该可以为此使用logstash。它将为您提供一组输入(例如文件)的事件流,并为您提供可以推送到另一个输出(例如文件)的数据流。它还将为您提供许多未来增长的选择,同时在短期内易于设置。

http://www.logstash.net/

于 2013-04-11T21:43:49.717 回答