检测文件内容变化的命令

18 views
Skip to first unread message

lizongyao

unread,
Sep 14, 2015, 6:17:33 AM9/14/15
to sh...@googlegroups.com
Linux下有没有一种可以检测文件内容变化的命令  

现在有个需求是:当文件内容发生变化(无论是增加还删除),然后我执行某些操作


Chaos Eternal

unread,
Sep 14, 2015, 7:43:43 AM9/14/15
to sh...@googlegroups.com
inotify

2015-09-14 18:17 GMT+08:00 lizongyao <mwu...@hotmail.com>:
> Linux下有没有一种可以检测文件内容变化的命令
>
> 现在有个需求是:当文件内容发生变化(无论是增加还删除),然后我执行某些操作
>
>
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/shlug?hl=zh-CN
> ---
> 您收到此邮件是因为您订阅了Google网上论坛上的“Shanghai Linux User Group”群组。
> 要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
> 要查看更多选项,请访问https://groups.google.com/d/optout

Bingxiang Chu

unread,
Sep 14, 2015, 9:09:28 AM9/14/15
to sh...@googlegroups.com
貌似有linux C里面个东西叫做inotify,你可以写个小程序试试

Simon Zheng

unread,
Sep 15, 2015, 2:08:04 AM9/15/15
to Shanghai Linux User Group
python 有个library叫 watchdog, 挺方便的

在 2015年9月14日星期一 UTC+8下午6:17:33,李洛写道:
Linux下有没有一种可以检测文件内容变化的命令  

现在有个需求是:当文件内容发生变化(无论是增加还删除),然后我执行某些操作


muxueqz(张明源)

unread,
Sep 15, 2015, 3:01:33 AM9/15/15
to sh...@googlegroups.com
还可以用auditd

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问https://groups.google.com/d/optout

Yang Fan

unread,
Sep 15, 2015, 5:53:27 AM9/15/15
to sh...@googlegroups.com
inotify_wait  write_close

2015-09-14 18:17 GMT+08:00 lizongyao <mwu...@hotmail.com>:
Linux下有没有一种可以检测文件内容变化的命令  

现在有个需求是:当文件内容发生变化(无论是增加还删除),然后我执行某些操作


--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问https://groups.google.com/d/optout



--
Regards,
Fan Yang

mwumli

unread,
Sep 15, 2015, 8:01:09 AM9/15/15
to sh...@googlegroups.com
好的,谢谢各位,我回头试一下,哈哈



发自我的小米手机
在 Yang Fan <miss...@gmail.com>,2015年9月15日 下午5:53写道:

Terry Wang

unread,
Sep 16, 2015, 8:55:05 PM9/16/15
to Shanghai Linux User Group
文件系统级别的审计只有 audit 靠谱,能追查到事件的系统调用、用户和组、进程 ID (包括父进程)、运行的命令及其二进制的全路径。

另一个 inotify-tools 做不到如此细致,貌似最多到各种事件计数(访问/修改/属性/打开/创建)和文件名。

Reference: tweet@terrywang

On Monday, 14 September 2015 20:17:33 UTC+10, 李洛 wrote:
Linux下有没有一种可以检测文件内容变化的命令  

现在有个需求是:当文件内容发生变化(无论是增加还删除),然后我执行某些操作


muxueqz(张明源)

unread,
Sep 16, 2015, 9:48:28 PM9/16/15
to sh...@googlegroups.com
嗯,当初正是因为这个缘故,我才用了auditd

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问https://groups.google.com/d/optout



--
Reply all
Reply to author
Forward
0 new messages