bash - 如何将一个 rsync 进程优先于另一个?
问题描述
我在 Red Hat 实例上运行了两个单独的 cronjobs。两者都通过 rsync 将日志文件从远程服务器复制到实例。第一个 cronjob 运行rsync-new.sh
,它从服务器上的各个目录复制任何新的日志文件(从今天或昨天开始)。第二个 cronjob 运行rsync-backfill.sh
,它复制所有比昨天更旧的日志文件。我分离了 rsync 进程,以便始终快速复制新文件,并且大型回填作业不会干扰新文件的复制。
这通常有效,但以下情况除外:如果rsync-backfill.sh
已经从文件夹中复制旧文件,则在完成该文件夹rsync-new.sh
之前不会复制其文件。rsync-backfill.sh
有没有办法让 rsync 命令的优先级rsync-new.sh
高于 rsync 命令的优先级rsync-backfill.sh
?或者至少让 rsync 命令并行运行,以便始终快速复制新文件?
这是一般的脚本结构:
rsync-new.sh
for SUBDIR in $(ls $SOURCEDIR)
do
rsyc -zt \
--exclude-from=$TRACKERFILE \
--out-format="%n" \
$SOURCEDIR/$SUBDIR/log-$TODAY*.log $DESTDIR/ | tee -a $TRACKERFILE
done
for SUBDIR in $(ls $SOURCEDIR)
do
rsyc -zt \
--exclude-from=$TRACKERFILE \
--out-format="%n" \
$SOURCEDIR/$SUBDIR/log-$YESTERDAY*.log $DESTDIR/ | tee -a $TRACKERFILE
done
rsync-backfill.sh
for SUBDIR in $(ls $SOURCEDIR)
do
rsyc -zt \
--exclude-from=$TRACKERFILE \
--exclude="log-$TODAY*.log" \
--exclude="log-$YESTERDAY*.log" \
--out-format="%n" \
$SOURCEDIR/$SUBDIR/log-*.log $DESTDIR/ | tee -a $TRACKERFILE
done
解决方案
This is a non-issue, turns out it was just a coincidence that the new log files for one of the directories weren't syncing until after the backfill was complete (the new log files just happened to be much larger than the backfill files).
Cron runs jobs in isolated environments, so the rsync processes weren't interacting with each other.
推荐阅读
- javascript - Highcharts 词云 - 为每个词创建链接
- javascript - 如何处理 react.js 中下拉菜单的 onClick 更改
- asp.net - ASP.NET 超链接
- c++ - 依次加载多个 QML 弹出窗口组件
- asp.net - 如何为自托管的 MVC 4 API 控制器配置依赖注入
- websphere - Websphere应用服务器8.5
- javascript - jQuery slideToggle 页面刷新的反向效果
- c# - 如何在 CustomAuthorizeAttribute 之后禁用重定向到 /identity/account/login?
- amazon-web-services - Facebook 认为我们的网站 URL 无效
- git - 我想从 GitHub 恢复还原的更改