使用 inotifywait的方式监控文件夹发生变化后自动执行脚本的方法
0. 先安装inotify 最简单的方法为:
yum install epel-release
安装扩展包源
yum install inotify-tools
1. 从网上抄了一下脚本 简单记录一下
编写脚本如下:
srcdir="/在测补丁"
inotifywait -mrq --timefmt '%d/%m/%y-%H:%M' --format '%T%w%f' -e modify,create,attrib ${srcdir} \
| while read file
do
/deploy/cicd
done
定义一下 source的目录 然后 通过 inotifywait的命令 监听 文件夹的变化
如果检测到文件发生变化 执行 批处理
仔细看一下帮助如下:
[root@centos76 deploy]# 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>
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
使用 inotifywait的方式监控文件夹发生变化后自动执行脚本的方法的更多相关文章
- [转帖]Linux下inotify监控文件夹状态,发生变化后触发rsync同步
Linux下inotify监控文件夹状态,发生变化后触发rsync同步 https://www.cnblogs.com/fjping0606/p/6114123.html 1.安装工具--inotif ...
- Python 的 pyinotify 模块 监控文件夹和文件的变动
官方参考: https://github.com/seb-m/pyinotify/wiki/Events-types https://github.com/seb-m/pyinotify/wiki/I ...
- Storm监控文件夹变化 统计文件单词数量
监控指定文件夹,读取文件(新文件动态读取)里的内容,统计单词的数量. FileSpout.java,监控文件夹,读取新文件内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- 【.Net 学习系列】-- FileSystemWatcher 监控文件夹新生成文件,并在确认文件没有被其他程序占用后将其移动到指定文件夹
监控文件夹测试程序: using System; using System.Collections.Generic; using System.IO; using System.Linq; using ...
- postman---postman文件夹介绍以及批量执行用例
我们在做测试的过程中,都会多次请求接口,都会把接口保存下来,方便下次直接请求,节省时间不用每次都重新输入,我们一起看下Postman如何保存接口会话 保存请求作用 Postman可以将各个请求组合保存 ...
- 从加载DLL的中获取放置于Resources文件夹中资源字典的几种方法
原文:从加载DLL的中获取放置于Resources文件夹中资源字典的几种方法 主程序 为 Main_Test.exe 被加载的DLL 为 Load_Test.dll 此DLL 中 有一个 文件夹Re ...
- 用批处理文件自动备份文件及文件夹,并自动删除n天前的文件
原文:用批处理文件自动备份文件及文件夹,并自动删除n天前的文件 ---恢复内容开始--- 下是备份的批处理,添加到"计划任务"中,设定时间自动运行 复制代码 代码如下:@echo ...
- 树莓派Ubuntu 16.04 MATA系统 修改用户文件夹名后,提示configure it with blueman-service
自从修改了树莓派的Ubuntu 16.04 MATA 系统的 /home/ 下的用户文件夹名后,使用vncserver远程操作,看到桌面每次都提示 Configured directory for i ...
- linux上监控tomcat down掉后自动重启tomcat
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #454545 } p. ...
- Linux centosVMware 自动化运维Ansible介绍、Ansible安装、远程执行命令、拷贝文件或者目录、远程执行脚本、管理任务计划、安装rpm包/管理服务、 playbook的使用、 playbook中的循环、 playbook中的条件判断、 playbook中的handlers、playbook实战-nginx安装、管理配置文件
一.Ansible介绍 不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook,易于编写和阅读 安装十分简单,ce ...
随机推荐
- 云小课|MRS基础操作之配置DataNode容量均衡
阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要:当HDFS集群出现 ...
- 云图说|一张图看懂一站式DevOps利器——华为云DevCloud
阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要: 华为云DevCl ...
- 关于HTTPS认证,这里解决你所有疑惑
摘要:从签发证书到数据加密交互,按流程的进展讲解HTTPS认证过程内容和原理. 本文分享自华为云社区<故事+图文,一次性解决你对HTTPS认证过程的所有疑惑>,作者:breakDraw. ...
- 如何注册appuploader账号
如何注册appuploader账号 我们上一篇讲到appuploader的下载安装,要想使用此软件呢,需要注册账号才能使用,今 天我们来讲下如何注册appuploader账号来使用软件. 1.A ...
- 从飞书妙记秒开率提升,看火山引擎A/B测试在研发场景的应用
作者:DataTester 用户体验是决定互联网产品能否长久生存的关键,每一个基于产品功能.使用和外观的微小体验,都将极大地影响用户留存和满意度. 对于企业协作平台飞书而言,用户体验旅程从打开 ...
- Solon cloud 使用融断器 sentinel 或 guava 或 semaphore
Solon Cloud 是一套防腐层的架构方案.提供统一的接口定义和配置设计,从而实现不同框架统一体验的效果. 目前,已适配的融断器有三个插件且体验方式完全相同,分别是: sentinel-solon ...
- Mac Parallels (PD) 常规设置
Mac 上安装了 Parallels (PD) 程序默认使用 Parallels 打开,比较烦人,取消设置: 虚机中不显示 mac 的菜单栏 ,按 Control + Option 就会临时显示 备份 ...
- JWT token验证后,通过 ThreadLocal 进行传值
Spring Boot JWT 用户认证 JWT token验证后,通过 ThreadLocal 进行传值,在服务层直接使用 Threadlocal 获取当前用户,的Id.姓名,进行行为记录 定义一个 ...
- 【已解决】无法打开.xlsx文件,xlrd.biffh.XLRDError: Excel xlsx file; not supported
原因是最近xlrd更新到了2.0.1版本,只支持.xls文件.所以x1 = xlrd.open_workbook("data.xlsx")会报错. 可以安装旧版xlrd,在cmd中 ...
- C# Task 多任务:C# 扩展TaskScheduler实现独立线程池,支持多任务批量处理,互不干扰,无缝兼容Task
先上源码: https://gitee.com/s0611163/TaskSchedulerEx 为什么编写TaskSchedulerEx类? 因为.NET默认线程池只有一个线程池,如果某个批 ...