[CentOS-mirror] lock files

Wed Aug 5 23:31:08 UTC 2009
Nick Olsen <Nick at 141networks.com>

Lesson learned for all,
When you run the script it just runs the screen command, which the rsync
runs in.
So the script completes because its run the screen command, Thus running
the rm -rf on the lock file :) thanks for all the help David.

-----Original Message-----
From: centos-mirror-bounces at centos.org
[mailto:centos-mirror-bounces at centos.org] On Behalf Of David Richardson
Sent: Wednesday, August 05, 2009 7:20 PM
To: Mailing list for CentOS mirrors.
Subject: Re: [CentOS-mirror] lock files

On Wed, 5 Aug 2009, Nick Olsen wrote:

> Ok I think I got it, just one more thing. If I make the lock file
myself
> with the date >> /tmp/update-centos.lock file it works and doesn't let
> another one spawn. However. If its not there its not creating it. Do I
> have the else part in the right spot?
>
> #!/bin/bash
>
> if [ -f /tmp/update-centos.lock ]
>    # It does exist.
>    # Exit here so we don't screw up a run in-progress
>    then echo "Lock file exists" && exit 1
>    # No, it doesn't exist.
>    # Create the lock file so another run won't start.
>    else date >> /tmp/update-centos.lock
> fi
>
> ### Now we can do the actual rsync. At this point, we know that only
one
> ### copy of the script is running.
>
> ### Big long rsync command ###
> echo "Starting centos rsync"
> screen -A -m -d -S centos rsync -vaH --numeric-ids --delete
> --delete-after --delay-updates  --progress
> rsync://linux.mirrors.es.net/centos/ /home/www/centos
> DATE=`date`
> echo "$DATE with mirror linux.mirrors.es.net" >
> /home/www/txt/centostime.txt
>
> # Now we're done. Remove the lock file.
> /bin/rm -rf /tmp/update-centos.lock


Hmm. What happens if you remove screen from the picture (that is, have
the 
script run the rsync directly)?

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
_______________________________________________
CentOS-mirror mailing list
CentOS-mirror at centos.org
http://lists.centos.org/mailman/listinfo/centos-mirror