inotifywait & inotifywatch 参数设置

root@husky:/usr/local/inotify/bin# inotifywait -h
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> 排除指定的事件,类似于--exclude,但是不区分大小写
                      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  类似于monitor,但是在后台运行
                      logging events to a file specified by --outfile.  输出事件至outfile指定文件
                      Implies --syslog.   输出日志至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.   打印事件至outfile
    -s|--syslog       Send errors to syslog rather than stderr.  保存错误日志到syslog,而不是输出错误
    -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.   以csv格式打印事件
    -t|--timeout <seconds>   设置超时范围,即多少s后不再监听;如果设置为0,表示永不过时
                      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    ???和delete有什么区别
    unmount        file system containing file or directory unmounted    包含已卸载文件或目录的文件系统



 



 root@husky:/usr/local/inotify/bin# inotifywatch -h
inotifywatch 3.14
Gather filesystem usage statistics using inotify.
Usage: inotifywatch [ options ] file1 [ file2 ] [ ... ]
Options:
    -h|--help        Show this help text.
    -v|--verbose     Be verbose.
    @<file>           Exclude the specified file from being watched.
    --fromfile <file>
        Read files to watch from <file> or `-' for stdin.
    --exclude <pattern>
        Exclude all events on files matching the extended regular
        expression <pattern>.
    --excludei <pattern>
        Like --exclude but case insensitive.
    -z|--zero   在最终的结果表中输出行和列,即使全部为0
        In the final table of results, output rows and columns even
        if they consist only of zeros (the default is to not output
        these rows and columns).
    -r|--recursive    Watch directories recursively.
    -t|--timeout <seconds>
        Listen only for specified amount of time in seconds; if
        omitted or 0, inotifywatch will execute until receiving an
        interrupt signal.
    -e|--event <event1> [ -e|--event <event2> ... ]
        Listen for specific event(s).  If omitted, all events are 
        listened for.
    -a|--ascending <event>
        Sort ascending by a particular event, or `total'.  升序排列
    -d|--descending <event>
        Sort descending by a particular event, or `total'.    降序排列

Exit status:
    0  -  Exited normally.  正常退出
    1  -  Some error occurred.   发生错误

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

注:

  • 以上是inotifywait和inotifywatch的参数部分,两者相同部分未标注
  • 里面的delete_self不太明白,留待以后解决

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值