rsync cronjob只有在rsync尚未运行时才会运行

编程入门 行业动态 更新时间:2024-10-23 08:33:24
本文介绍了rsync cronjob只有在rsync尚未运行时才会运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在这里检查了一个解决方案,但似乎找不到一个。我处理一个非常慢的wan连接约300kb /秒。对于我的下载我使用一个遥控盒,然后我下载他们到我家。我试图运行一个cronjob,将rsync两个目录在我的远程和本地服务器每小时。我得到一切工作,但如果有很多数据传输rsyncs重叠,并结束创建同一个文件的两个实例,因此重复的数据发送。

I have checked for a solution here but cannot seem to find one. I am dealing with a very slow wan connection about 300kb/sec. For my downloads I am using a remote box, and then I am downloading them to my house. I am trying to run a cronjob that will rsync two directories on my remote and local server every hour. I got everything working but if there is a lot of data to transfer the rsyncs overlap and end up creating two instances of the same file thus duplicate data sent.

我想

推荐答案

通过脚本,您可以创建一个脚本一个锁定文件。如果文件存在,cronjob应该跳过运行;否则应该继续。脚本完成后,应删除锁定文件。

Via the script you can create a "lock" file. If the file exists, the cronjob should skip the run ; else it should proceed. Once the script completes, it should delete the lock file.

if [ -e /home/myhomedir/rsyncjob.lock ] then echo "Rsync job already running...exiting" exit fi touch /home/myhomedir/rsyncjob.lock #your code in here #delete lock file at end of your job rm /home/myhomedir/rsyncjob.lock

更多推荐

rsync cronjob只有在rsync尚未运行时才会运行

本文发布于:2023-07-16 04:13:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117722.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时才   rsync   cronjob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!