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的方式监控文件夹发生变化后自动执行脚本的方法的更多相关文章

  1. [转帖]Linux下inotify监控文件夹状态,发生变化后触发rsync同步

    Linux下inotify监控文件夹状态,发生变化后触发rsync同步 https://www.cnblogs.com/fjping0606/p/6114123.html 1.安装工具--inotif ...

  2. Python 的 pyinotify 模块 监控文件夹和文件的变动

    官方参考: https://github.com/seb-m/pyinotify/wiki/Events-types https://github.com/seb-m/pyinotify/wiki/I ...

  3. Storm监控文件夹变化 统计文件单词数量

    监控指定文件夹,读取文件(新文件动态读取)里的内容,统计单词的数量. FileSpout.java,监控文件夹,读取新文件内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...

  4. 【.Net 学习系列】-- FileSystemWatcher 监控文件夹新生成文件,并在确认文件没有被其他程序占用后将其移动到指定文件夹

    监控文件夹测试程序: using System; using System.Collections.Generic; using System.IO; using System.Linq; using ...

  5. postman---postman文件夹介绍以及批量执行用例

    我们在做测试的过程中,都会多次请求接口,都会把接口保存下来,方便下次直接请求,节省时间不用每次都重新输入,我们一起看下Postman如何保存接口会话 保存请求作用 Postman可以将各个请求组合保存 ...

  6. 从加载DLL的中获取放置于Resources文件夹中资源字典的几种方法

    原文:从加载DLL的中获取放置于Resources文件夹中资源字典的几种方法 主程序 为 Main_Test.exe 被加载的DLL 为 Load_Test.dll  此DLL 中 有一个 文件夹Re ...

  7. 用批处理文件自动备份文件及文件夹,并自动删除n天前的文件

    原文:用批处理文件自动备份文件及文件夹,并自动删除n天前的文件 ---恢复内容开始--- 下是备份的批处理,添加到"计划任务"中,设定时间自动运行 复制代码 代码如下:@echo ...

  8. 树莓派Ubuntu 16.04 MATA系统 修改用户文件夹名后,提示configure it with blueman-service

    自从修改了树莓派的Ubuntu 16.04 MATA 系统的 /home/ 下的用户文件夹名后,使用vncserver远程操作,看到桌面每次都提示 Configured directory for i ...

  9. linux上监控tomcat down掉后自动重启tomcat

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #454545 } p. ...

  10. Linux centosVMware 自动化运维Ansible介绍、Ansible安装、远程执行命令、拷贝文件或者目录、远程执行脚本、管理任务计划、安装rpm包/管理服务、 playbook的使用、 playbook中的循环、 playbook中的条件判断、 playbook中的handlers、playbook实战-nginx安装、管理配置文件

    一.Ansible介绍 不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook,易于编写和阅读 安装十分简单,ce ...

随机推荐

  1. 关于汽车OTA,这篇科普文能告诉你

    随着汽车中软件发挥的作用越来越重要,软件定义汽车已经是行业内的共识.汽车行业的发展极有可能最终像手机产业一样,基础硬件差异会越来越小,关键在于汽车给用户的体验的多样性,以及汽车产品在不同场景下满足用户 ...

  2. 详解NLP和时序预测的相似性【附赠AAAI21最佳论文INFORMER的详细解析】

    摘要:本文主要分析自然语言处理和时序预测的相似性,并介绍Informer的创新点. 前言 时序预测模型无外乎RNN(LSTM, GRU)以及现在非常火的Transformer.这些时序神经网络模型的主 ...

  3. 五一高铁票难抢?用RPA机器人试试!

    随着信息数字化的高速发展,RPA在各行业中得到广泛应用,热度大增.这匹"技术黑马"已然成为构建业务流程自动化的重要引擎之一,助力企业组织向"智能自动化转型. 什么是RPA ...

  4. 云图说|OLAP开源引擎的一匹黑马,MRS集群组件之ClickHouse

    摘要:ClickHouse是俄罗斯公司Yandex在2016年开源的高性能.开源联机分析列式数据库管理系统.开源后,凭借卓越的分析性能.极好的线性扩展能力和丰富的功能,被业界公认为实时分析领域OLAP ...

  5. 火山引擎DataLeap的Data Catalog系统公有云实践

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 Data Catalog是一种元数据管理的服务,会收集技术元数据,并在其基础上提供更丰富的业务上下文与语义,通常支 ...

  6. python jira 取提出指向未解决的问题

    #!/usr/bin/python # -*- coding: utf-8 -*- import sys, os,time,requests,datetime import schedule from ...

  7. BBS项目(五):xss攻击 上传图片问题 文章编辑、删除功能 用户头像修改 扩展部分

    目录 添加文章功能完善 富文本编辑器上传图片问题 文章编辑功能 文章删除功能 用户头像修改 扩展部分 补充 项目总结 添加文章功能完善 下载第三方模块: pip install bs4 pip ins ...

  8. 阿里云视频云vPaaS低代码音视频工厂:极速智造,万象空间

    当下音视频技术越来越广泛地应用于更多行各业中,但因开发成本高.难度系数大等问题,掣肘了很多企业业务的第二增长需求.阿里云视频云基于云原生.音视频.人工智能等先进技术,提供易接入.强拓展.高效部署和覆盖 ...

  9. Hystrix 如何解决 ThreadLocal 信息丢失

    本文分享 ThreadLocal 遇到 Hystrix 时上下文信息传递的方案. 一.背景 笔者在业务开发中涉及到使用 ThreadLocal 来存放上下文链路中一些关键信息,其中一些业务实现对外部接 ...

  10. 制作PE工具箱

    事前准备: 能上网的电脑 x1 台 大于8G的U盘 x一个(如果需要储存安装镜像的话,如果不需要的话大于1G即可) 一.下载PE工具箱 推荐使用WEPE工具箱,无广告无推广.不推荐老X桃,大X菜,大X ...