[CentOS-mirror] lock files
David Richardson
david.richardson at utah.edu
Wed Aug 5 22:58:40 UTC 2009
On Wed, 5 Aug 2009, Nick Olsen wrote:
> I run a private centos mirror. Using rsync from the es.net mirror
>
> I?m sure you get this all the time, but how do I use lock files with the
> rsync client to keep multiple from spawning because of cron jobs?
>
> My mirror also hosts ubuntu and a few others which run at the same time,
> if this info is needed.
>
> Right now the cron job just SH?s a script containing a screen call with
> the rsync command in it. And I would like to keep it this way. At least
> that sh script. What im really looking for is a script that checks for
> the lockfile if its running. And then if its not SH?s the script. I
> would have the cron job run that script, and that script would run my
> sh script called centos.sh located in /root/
On my mirror, I have a separate script for each project I mirror. My
update-centos.sh script looks like this:
### update-centos.sh
#!/bin/bash
### Lock file
if [ -f /tmp/update-centos.lock ]
then echo "Lock file exists" && exit 1
else
date >> /tmp/update-centos.lock
fi
### Big long rsync command ###
### Remove lock file
/bin/rm -rf /tmp/update-centos.lock
### end update-centos.sh
I also have /etc/rc.local remove the lock files for all my scripts (in
case I reboot during a run):
# /etc/rc.local
/bin/rm /tmp/update.lock >/dev/null 2>&1
Hope this helps.
DR
--
David Richardson <david.richardson at utah.edu>
"There are two kinds of statistics: the
kind you look up and the kind you make up."
-- Archie Goodwin, Death of a Doxy
More information about the CentOS-mirror
mailing list