inotify主要功能

  Inotify 是一个 Linux特性,它监控文件系统操作,比如读取、写入和创建。Inotify 反应灵敏,用法非常简单,并且比 cron 任务的繁忙轮询高效得多。学习如何将 inotify 集成到您的应用程序中,并发现一组可用来进一步自动化系统治理的命令行工具。更加详细介绍查看百科介绍

  Linux内核从2.6.13开始,引入了inotify机制。通过intofity机制,能够对文件系统的变化进行监控,如对文件进行创建、删除、修改等操作,可以及时通知应用程序进行相关事件的处理。这种响应处理机制,避免了频繁的文件轮询任务,提高了任务的处理效率。

inotify安装(操作在centos6.5系统实现)

  1. 检查系统内核
[root@node1 ~]# uname -a
Linux node1 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  1. 检查是否支持inotify,出现以下结果表明支持
[root@node1 ~]# ls -l /proc/sys/fs/inotify/
total 0
-rw-r--r-- 1 root root 0 Jun 24 01:30 max_queued_events
-rw-r--r-- 1 root root 0 Jun 24 01:30 max_user_instances
-rw-r--r-- 1 root root 0 Jun 24 01:30 max_user_watches
  1. 检查是否安装inotify
[root@node1 ~]# rpm -qa inotify-tools
inotify-tools-3.14-1.el6.x86_64

出现以上命令表明已经安装inofity,否则通过以下方式添加安装员,在线安装:

[root@node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
[root@node1 ~]# rpm -y install inotify-tools
  1. 查看inotifywait命令,确认安装成功
[root@node1 ~]# which inotifywait
/usr/bin/inotifywait

参数详解

[root@node1 ~]# inotifywait --help
inotifywait 3.14
Wait for a particular event on a file or set of files.
Usage: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ ... ]
Options:
-h|--help Show this help text.
@<file> Exclude the specified file from being watched.
--exclude <pattern>
Exclude all events on files matching the
extended regular expression <pattern>.
--excludei <pattern>
Like --exclude but case insensitive. 排除文件或者目录的时候不区分大小写
-m|--monitor Keep listening for events forever. Without
this option, inotifywait will exit after one
event is received. 始终保持事件监听状态
-d|--daemon Same as --monitor, except run in the background
logging events to a file specified by --outfile.
Implies --syslog.后台运行
-r|--recursive Watch directories recursively. 递归查询目录
--fromfile <file>
Read files to watch from <file> or `-' for stdin.
-o|--outfile <file>
Print events to <file> rather than stdout.
-s|--syslog Send errors to syslog rather than stderr.
-q|--quiet Print less (only print events).打印很少的信息,仅仅打印监控事件的信息 安静状态
-qq Print nothing (not even events).
--format <fmt> Print using a specified printf-like format
string; read the man page for more details.
--timefmt <fmt> strftime-compatible format string for use with
%T in --format string.指定时间输出的格式
-c|--csv Print events in CSV format.
-t|--timeout <seconds>
When listening for a single event, time out after
waiting for an event for <seconds> seconds.
If <seconds> is 0, inotifywait will never time out.
-e|--event <event1> [ -e|--event <event2> ... ]
Listen for specific event(s). If omitted, all events are
listened for. 事件 Exit status:
0 - An event you asked to watch for was received.
1 - An event you did not ask to watch for was received
(usually delete_self or unmount), or some error occurred.
2 - The --timeout option was given and no events occurred
in the specified interval of time. Events:
access file or directory contents were read
modify file or directory contents were written
attrib file or directory attributes changed
close_write file or directory closed, after being opened in
writeable mode
close_nowrite file or directory closed, after being opened in
read-only mode
close file or directory closed, regardless of read/write mode
open file or directory opened
moved_to file or directory moved to watched directory
moved_from file or directory moved from watched directory
move file or directory moved to or from watched directory
create file or directory created within watched directory
delete file or directory deleted within watched directory
delete_self file or directory was deleted
unmount file system containing file or directory unmounted

Linux系统inotify工具安装配置的更多相关文章

  1. 【Oracle RAC】Linux系统Oracle11gR2 RAC安装配置详细过程V3.1(图文并茂)

    [Oracle RAC]Linux系统Oracle11gR2 RAC安装配置详细过程V3.1(图文并茂) 2 Oracle11gR2 RAC数据库安装准备工作2.1 安装环境介绍2.2 数据库安装软件 ...

  2. 【Oracle RAC】Linux系统Oracle12c RAC安装配置详细记录过程V2.0(图文并茂)

    [Oracle RAC]Linux系统Oracle12c RAC安装配置详细过程V2.0(图文并茂) 2 Oracle12c RAC数据库安装准备工作2.1 安装环境介绍2.2 数据库安装软件下载3 ...

  3. 【Oracle RAC】Linux系统Oracle18c RAC安装配置详细记录过程(图文并茂)

    本文Oracle 18c GI/RAC on Oracle Linux step-by-step 的安装配置步骤,同时也包含dbca 创建数据库的过程. 1. 关闭SELINUX,防火墙vi /etc ...

  4. Linux系统Java环境安装配置

    jdk安装配置 首先下载JDK和JRE,这里你的需要看看你的Linux系统是多少位的,比如我的是64位的: 下载JDK并指定到Download目录,JRE同样操作: 解压并且配置环境: tar -zx ...

  5. centos 7 linux系统默认ftp安装配置和部署(详细讲解)

    小生接触 Linux 系统时间不长,想解决linux系统ftp安装及部署问题,折腾了大半天,终于弄出来了,将各路高手的配置方法综合了一下,如有不对之处,欢迎各位看客指正,感谢! 一.声明: 本文采用操 ...

  6. Linux系统下tomcat安装配置

    Linux系统中Tomcat的安装配置. 前提JDK已经安装好. 安装 下载tomcatwget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0 ...

  7. linux系统下jdk安装配置

    1.有jdk包(linux版) 2.放到linux系统下 3.建议在usr下新建jdk目录之后将jdk文件放到该目录下 3.配置系统信息   /etc/profile 需要配置的信息如下:#set j ...

  8. 在Debian系列Linux系统Ubuntu上安装配置yum的试验

    用习惯了Red Hat系统的都知道我们习惯于三种安装方式:一种是rpm包的方式安装,一种就是tar包的方式来安装,还有一种方式就是yum源的安装. 首先rpm包的用法,我们一般是在Red Hat光驱里 ...

  9. Linux系统下JDK安装配置(转载)

    转载出处:http://www.cnblogs.com/xuliangxing/p/7066913.html 本文主要介绍的是如何是Linux环境下安装JDK的,因为Linux环境下,很多时候也离不开 ...

随机推荐

  1. Asset Catalogs

    原文见这里. Asset Catalogs用于简化管理程序内用到的图片.每个asset catalog可以包含image set, App Icon, Launch Image和OS X Icon(如 ...

  2. 奇(qi)谋(ji)巧(yin)计(qiao)

    一.打表法 0.http://oeis.org/ 1.差分序列:https://blog.csdn.net/wu_tongtong/article/details/79115921 对于一个多项式产生 ...

  3. Java中Date类型如何向前向后滚动时间,( 附工具类)

    Java中的Date类型向前向后滚动时间(附工具类) 废话不多说,先看工具类: import java.text.SimpleDateFormat; import java.util.Calendar ...

  4. Sass变量及嵌套

    1. 变量:SASS允许使用变量,所有变量以$开头. 变量声明:$highlight-color: #000; 注意:变量可以在css规则块定义之外存在.如下例子: $nav-color: #F90; ...

  5. spring-集成redis

    Redis是key-value存储的非关系型数据库.Spring Data Redis包含了多个模板实现,用来完成Redis数据库的数据存取功能 1.如何连接Redis? Spring Data Re ...

  6. windows service 2012:搭建FTP服务器

    最近公司将服务器从线上移植到线下每次上传项目都要进入服务器感觉好麻烦, 所以就想搭建一个FTP的站点来管理项目,弄这个之前首先要关闭我们的windows service 2012 服务器的防火墙,只有 ...

  7. PHP基础4--函数-数组

    主要 函数 数组 常用系统函数 函数 基础 1)定义 function 函数名([$形参1],[$形参2],.....) { //函数体 } 点击查看函数定义形式 2) 调用 函数名([$实参1][, ...

  8. 对QP中RTC的理解

    1.概念 RTC(Run To Completion)是运行到完成为止的意思.在状态机中,从源状态到目标状态的转换动作要运行到完成. 从字面上来看,这个过程像是不可中断的,但实际并不是,这个过程可以被 ...

  9. LCD驱动程序编写

    学习目标:编写LCD驱动程序,熟悉根据芯片手册分析时序图,配置寄存器,并测试LCD程序. 一.LCD驱动程序编写 步骤: 1)分配fb_info结构体 2)设置fb_info结构体 a. 固定参数 b ...

  10. python学习笔记:第13天 内置函数(一)

    详细文件查看点击这里:详细地址