简体   繁体   English

检测 unix 中的目录变化

[英]Detect directory changes in unix

How could I track changes of specific directory in UNIX?如何跟踪 UNIX 中特定目录的更改? For example, I launch some utility which create some files during its execution.例如,我启动了一些在执行过程中创建一些文件的实用程序。 I want to know what exact files were created during one particular launch.我想知道在一次特定发布期间创建了哪些确切文件。 Is there any simple way to get such information?有没有简单的方法来获取这些信息? Problem is that:问题在于:

  1. I cannot flush directory content after script execution脚本执行后我无法刷新目录内容
  2. Files created with the name that has hash as a compound part.使用具有哈希作为复合部分的名称创建的文件。 There is no possibility to get this hash from script for subsequent search.无法从脚本中获取此哈希值以进行后续搜索。
  3. There could be several scripts executed simultaneously, I do not want to see files created by another process in the same folder.可能有多个脚本同时执行,我不想在同一文件夹中看到另一个进程创建的文件。

Please notice that I do not want to know whether directory has been changed as stated here , I need filenames which ideally could be grepped to match specific pattern.请注意,我不想知道目录是否已按照此处所述进行更改,我需要理想情况下可以匹配特定模式的文件名。

您需要订阅文件系统更改通知

您应该使用诸如 FAM、gamin 或 inotify 之类的东西来检测文件何时被创建、关闭等。

您可以使用strace -f myscript跟踪脚本进行的所有系统调用,并使用grep过滤创建新文件的系统调用。

您可以使用script命令来跟踪启动的命令。

You could use the Linux Auditing System.您可以使用 Linux 审计系统。 Here is a howto link:这是一个操作方法链接:

http://www.cyberciti.biz/tips/linux-audit-files-to-see-who-made-changes-to-a-file.html http://www.cyberciti.biz/tips/linux-audit-files-to-see-who-made-changes-to-a-file.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM