inotify-tool的使用
来源:互联网 发布:mac怎么导入硬盘照片 编辑:程序博客网 时间:2024/06/11 11:27
inotify-tool中有个inotifywait工具
inotifywait 命令参数说明:
-m 选项表示 monitor ,即开启监视
-r 选项表示递归监视,但是会比较慢一些,若监视/etc 目录,其中的子目录下修改文件也是能被监控到。
-e 选项指定要监控的“事件”(events)包括了:access、modify、 attrib、 close_write、 close_nowrite、close、open、 moved_to、 moved_from、move、 move_self、 create、delete、delete_self、unmount。
1. 如果修改了/etc/passwd文件,则把这个事件记录在文件/root/modify_passwd.txt里
2. inotifywait -m /etc/passwd -e modify > /root/modify_passwd.txt
如果不加参数-e的话,默认就是监控所有的事件,在日常运维时,这个工具可以帮助你监控服务器上重要文件和重要目录的变化情况。
安装
cd /tmp
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure&&make&&make install
如果是32位系统
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib/libinotifytools.so.0
如果是64位系统
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
使用shell脚本调用inotifywait
# vim /tmp/mon.sh
#!/bin/bash
#可以将监控输出到指定文件夹
inotifywait -mr -o/home/chen/Workspace/temp/log.txt -e create /home/chen/Workspace/temp/
#可以将监控输出到控制台%f文件名,%e监控的目录
#inotifywait -mrq --timefmt '%F %T'--format '%T %w %f %e' -e create /home/chen/Workspace/temp/
做成开机启动
chmod u+x /tmp/mon.sh
echo "nohup /bin/bash /tmp/mon.sh &" >> /etc/rc.d/rc.local
nohup /bin/bash /tmp/mon.sh &
inotifywait 命令参数说明:
-m 选项表示 monitor ,即开启监视
-r 选项表示递归监视,但是会比较慢一些,若监视/etc 目录,其中的子目录下修改文件也是能被监控到。
-e 选项指定要监控的“事件”(events)包括了:access、modify、 attrib、 close_write、 close_nowrite、close、open、 moved_to、 moved_from、move、 move_self、 create、delete、delete_self、unmount。
1. 如果修改了/etc/passwd文件,则把这个事件记录在文件/root/modify_passwd.txt里
2. inotifywait -m /etc/passwd -e modify > /root/modify_passwd.txt
如果不加参数-e的话,默认就是监控所有的事件,在日常运维时,这个工具可以帮助你监控服务器上重要文件和重要目录的变化情况。
安装
cd /tmp
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure&&make&&make install
如果是32位系统
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib/libinotifytools.so.0
如果是64位系统
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
使用shell脚本调用inotifywait
# vim /tmp/mon.sh
#!/bin/bash
#可以将监控输出到指定文件夹
inotifywait -mr -o/home/chen/Workspace/temp/log.txt -e create /home/chen/Workspace/temp/
#可以将监控输出到控制台%f文件名,%e监控的目录
#inotifywait -mrq --timefmt '%F %T'--format '%T %w %f %e' -e create /home/chen/Workspace/temp/
做成开机启动
chmod u+x /tmp/mon.sh
echo "nohup /bin/bash /tmp/mon.sh &" >> /etc/rc.d/rc.local
nohup /bin/bash /tmp/mon.sh &
0 0
- inotify-tool的使用
- inotify-tool 简单使用
- inotify-tool和rsync
- INotify的介绍和使用
- inotify使用
- inotify使用
- inotify使用
- i2c tool 的使用
- i2c tool 的使用
- 【tool】logminer的使用
- 一段失败的代码 inotify的使用
- 使用 inotify 监控文件系统的活动
- 使用 inotify 监控文件系统的活动
- 使用 inotify 监控文件系统的活动
- 使用 inotify 监控文件系统的活动
- c语言使用inotify的实例
- 使用 inotify 监控文件系统的活动
- 使用 inotify 监控文件系统的活动
- 自动换行的方法,总有一种适合你的解决方案
- gitconfig备份
- Oracle RAC 集群 SCAN 说明
- Are SQL server Jobs Currently Running?
- POI导出EXCEL经典实现
- inotify-tool的使用
- test
- 监控行业常见视频格式
- 《老罗的Android之旅》阅读笔记——SurfaceFlinger服务
- 基于hadoop2.6.0的hbase0.96.2安装配置
- C++ UTF8编码转换 CChineseCode
- nyoj题目845:无主之地1
- Android布局RelativeLayout(相对布局)详解
- android 开发网址大全