免费招聘网站建设,微网站可以做商城吗,cloudflare cdn,重庆妇科医院排行inotifywait命令
【命令格式】: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ … ] 【命令原意】: inote file system wait 【命令路径】: 【命令功能】: 等待所监听的文件系统触发操作事件 【执行权限】: root 【命令描述】: 众所周知#xff0c;Linux 桌面系统与 …inotifywait命令
【命令格式】: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ … ] 【命令原意】: inote file system wait 【命令路径】: 【命令功能】: 等待所监听的文件系统触发操作事件 【执行权限】: root 【命令描述】: 众所周知Linux 桌面系统与 MAC 或 Windows 相比有许多不如人意的地方为了改善这种状况开源社区提出用户态需要内核提供一些机制以便用户态能够及时地得知内核或底层硬件设备发生了什么从而能够更好地管理设备给用户提供更好的服务如 hotplug、udev 和 inotify 就是这种需求催生的。Hotplug 是一种内核向用户态应用通报关于热插拔设备一些事件发生的机制桌面系统能够利用它对设备进行有效的管理udev 动态地维护 /dev 下的设备文件inotify 是一种文件系统的变化通知机制如文件增加、删除等事件可以立刻让用户态得知该机制是著名的桌面搜索引擎项目 beagle 引入的并在 Gamin 等项目中被应用。
Inotify 是一个内核用于通知用户空间程序文件系统变化的机制是基于inode级别的文件系统监控技术是一种强大的、细粒度的、异步的机制它满足各种各样的文件监控需要不仅限于安全和性能内核要求2.6.13以上inotify能监控非常多的文件系统事件通过监控这些事件来监控文件是否发生变更然后通过rsync来更新发生变更的文件Inotify 可以监视的文件系统事件包括【常用选项】: -h 或 --help 显示帮助
file Exclude the specified file from being watched.--exclude pattern 指定排除(忽略)部分文件或目录这些文件或目录上不监听任何事件正则表达式书写(相对路径)FMT: # --exclude Runtime //忽略对Runtime目录的事件监听--excludei pattern 与--exclude相同区别是此选项正则表达式忽略大小写-m 或 --monitor 持续保持监听(如果不加此选项则监听到一次后便退出)-d 或 --daemon 以守护进程方式后台运行(除了在后台运行外与-m选项一样)-r 或 --recursive 递归监听其下所有子目录及文件--fromfile file Read files to watch from file or - for stdin.-o 或 --outfile file 将事件输出到指定文件而不输出到屏幕FMT: -o /var/log/inotifywait.log-s 或 --syslog 将错误发送到系统日志而不是输出到屏幕-q 或 --quiet 打印较少信息(仅打印事件)-qq 不打印任何信息(静默方式)--format fmt 设置打印屏幕的格式常见选项%T时间%w触发事件文件所在绝对路径%f触发事件文件名称%e触发的事件名称FMT: # --format %T %f %e--timefmt fmt 指定输出时间内容相当于将时间赋值给%TFMT: # --timefmt %y-%m-%d %H:%M-c 或 --csv 用CSV格式打印事件-t 或 --timeout seconds 指定一次性监听时间超时退出监听(值为0表示永不超时单位:秒)不可与 -m -d 连用FMT: # -t 60 //设定监听60秒60秒内监听到事件立即退出如果监听不到事件60秒后也退出-e 或 --event event1 [ -e|--event event2 ... ] 指定要监听的事件(多个事件用逗号分割)FMT: # -e create,delete,close_write,attrib,moved_to【总结提示】:
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. 意外收到一个未监听的事件(如文件自删除umount及其它情况)
2 - The --timeout option was given and no events occurred in the specified interval of time. 当给定了超时选项设定时间内没有事件产生
Events: 事件 access file or directory contents were read 文件或目录被(访问)读取r modify file or directory contents were written 文件或目录被写入w attrib file or directory attributes changed 文件或目录属性变更【理由chmod更改属性】 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 文件或目录被移动进来【理由mv目录内重命名】 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 文件或目录被创建【理由mkdir创建目录】 delete file or directory deleted within watched directory 文件或目录被删除【理由rm删除】 delete_self file or directory was deleted 文件或目录自删除 unmount file system containing file or directory unmounted 文件系统取消挂载