其他分享
首页 > 其他分享> > 今日收获---inotify监控是否有新文件生成

今日收获---inotify监控是否有新文件生成

作者:互联网

1. 安装

yum -y install inotify-tools
# rpm -ivh inotify-tools-3.13-1.el6.rf.x86_64.rpm
# wget http://www.rpmfind.net/linux/mageia/distrib/7/x86_64/media/core/release/inotify-tools-3.20.1-1.mga7.x86_64.rpm

2. 命令

inotifywatch

inotifywatch -e access,modify -t 60 -r /linuxcool 

inotifywait

inotifywait -mqr --format %f -e create

shell脚本

vi /script/watch_merc.sh 
#!/bin/bash

MON_DIR=/data/starpos/merc
inotifywait -mqr -e create,delete,modify $MON_DIR |\
while read files; do
  echo "$(date +'%F %T') $files" >> /script/log/watch_merc.log
done

报错处理

报错

# Failed to watch XXX upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches’.

处理

cat /proc/sys/fs/inotify/max_user_watches # 默认值8192
echo 9999999 > /proc/sys/fs/inotify/max_user_watches

标签:文件,inotify,watch,watches,---,user,监控,tools
来源: https://www.cnblogs.com/i-xiaojun/p/15007862.html