使用inotify-tools监控Linux下记录文件及目录访问
2016-06-04 17:16
671 查看
1、下载
wget --no-check-certificate http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
2、环境预安装
yum install
gcc
3、编译
tar zxf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure
make
make install
4、一些小处理
如果是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
5、无论32或者64位系统都执行
echo 104857600 > /proc/sys/fs/inotify/max_user_watches
echo 'echo 104857600 > /proc/sys/fs/inotify/max_user_watches' >> /etc/rc.local
6、设置自启动
vi /etc/rc.local
加入下面的代码
/usr/local/bin/inotifywait -m -r -d -o/var/log/change.log --timefmt '%F %T' --format '%T %w%f %e' -e close_write -e create /usr/local/test
其中/var/log/change.log是日志路径,/usr/local/test是监控的网站路径
reboot重启生效
7、直接使用方法
inotifywait -m -r -d -o/var/log/change.log --timefmt '%F %T' --format '%T %w%f %e' -e close_write -e create /home/www
其中/var/log/change.log是日志路径,/home/www是监控的网站路径
wget --no-check-certificate http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
2、环境预安装
yum install
gcc
3、编译
tar zxf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure
make
make install
4、一些小处理
如果是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
5、无论32或者64位系统都执行
echo 104857600 > /proc/sys/fs/inotify/max_user_watches
echo 'echo 104857600 > /proc/sys/fs/inotify/max_user_watches' >> /etc/rc.local
6、设置自启动
vi /etc/rc.local
加入下面的代码
/usr/local/bin/inotifywait -m -r -d -o/var/log/change.log --timefmt '%F %T' --format '%T %w%f %e' -e close_write -e create /usr/local/test
其中/var/log/change.log是日志路径,/usr/local/test是监控的网站路径
reboot重启生效
7、直接使用方法
inotifywait -m -r -d -o/var/log/change.log --timefmt '%F %T' --format '%T %w%f %e' -e close_write -e create /home/www
其中/var/log/change.log是日志路径,/home/www是监控的网站路径
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- shell字符串操作详解
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法
- Shell脚本解压rpm软件包
- Linux Shell 数组建立及使用技巧
- Shell脚本实现复制文件到多台服务器的代码分享
- Shell脚本实现批量替换文件内容
- Shell脚本实现的一个简易Web服务器例子分享
- linux Shell学习笔记第五天