[TriLUG] creating a lock file

Jon Carnes jonc at nc.rr.com
Wed Jul 9 17:24:00 EDT 2003


On Wed, 2003-07-09 at 16:09, Joseph Tate wrote:
> Wrap your rsync commands in shell scripts.  Then use touch <FILENAME> to 
> create a file.  Use a structure like
> if [-f <FILENAME> ] then
>     exit;
> fi
> to test to see if it exists, then use rm <FILENAME> to remove the lock 
> file.  Just create a file.  If it exists, exit, if not, continue, and 
> remove it when you're finished.  I don't think there's a special "lock 
> file create, check, remove" command series.
> 
Exactly what I was going to say (and exactly how I do it).
Also, you can rsync the lock directory first.  Name the lock file after
the process that is running, so you can tell exactly which
script/process is blocking you.  Have your scripts retry after a a few
minutes and then send an error email if it cant' complete due to the
lock file.

Don't forget to wipe the local lockfile directory (or at least delete
the downloaded lockfile from there).

HtH - Jon Carnes

> JoJo Almario wrote:
> 
> > Every now and then someone puts a huge unwieldy file on the file 
> > server. My rsync backup runs into it and sometimes just halts on it.  
> > This will either cause other rsync scripts to run into it or it just 
> > halts there trying to copy it over, then I have a bunch of unfinished 
> > rsync processes runnning in the background.
> >
> > How do I create a lock file when this happens and how can I get the 
> > other rsync scripts to not run if there is a lock file present in a 
> > previous process?
> >
> 
> _______________________________________________
> TriLUG mailing list
>     http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ:
>     http://www.trilug.org/faq/TriLUG-faq.html




More information about the TriLUG mailing list