Re: At most 1 running copy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 27, 2004 at 09:48:31PM +0800, John Summerfield wrote:
> On Saturday 27 November 2004 12:49, Ed Wilts wrote:
> > For the record, this snippet works just fine (a per-user lock).
> >
> > use FileHandle;
> > use Fcntl qw(:DEFAULT :flock);
> > my $FH = new FileHandle;
> > sysopen(FH, "ftphandler.lock", O_RDWR | O_CREAT) or die "can't open
> > ftphandler.lock: $!"; flock(FH, LOCK_EX | LOCK_NB) or exit;
> > print "running...\n";
> > [rest of code here]
> > close (FH);
> > unlink ("ftphandler.lock");
> 
> 
> I nominated /var/run for a reason:-)
> It gets cleaned out on a reboot.

1.  /var/run is not world writable and I don't think it should be.  In
addition, I wanted to restrict the execution to once per user (actually
once per user input config file, but that's a different story), not once per
system.

2.  What's a reboot?  :-)

> Sure locks go, but it's nice to <plonk> the files too.

If ftphandler.lock hangs around because the job failed once, it will be
deleted the next time it's run successfully.  I could sweep through the
file system deleting old lock files too although I don't think it's
worth the effort.  That could be in cron.monthly and it would run far
more frequently than waiting for a reboot...

-- 
Ed Wilts, RHCE
Mounds View, MN, USA
mailto:ewilts@xxxxxxxxxx
Member #1, Red Hat Community Ambassador Program


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux