Linux&&shell使用

inotify+rsync

vim  /opt/inotify_rsync.sh
    #!/bin/bash
    #定义inotify命名行。实时监控
    INOTIFY_CMD="inotifywait  -mrq  -e  modify,create,attrib,move,delete  /var/www/html/"
    #定义rsync命令行。本地同步到远端。
    RSYNC_CMD="rsync  -azH  --delete  /var/www/html/  [email protected]:/var/www/html/"
    #启动inotify命名行 | 读取inotify产生的监控记录
    $INOTIFY_CMD | while read DIRECTORY EVENT FILE
    do
        #如果rsync未在执行,则立即启动。
        if [ $(pgrep ^rsync$ | wc -l) -le 0 ];then
            $RSYNC_CMD
        fi
    done

shell如何接收实参到形参?

方法一:read

read  -p  "please input values:"  a
echo $a
发布了73 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/dfq737211338/article/details/103899881
今日推荐