cron question / process queue

Kevin D. Clark kevin_d_clark at comcast.net
Fri Mar 7 15:21:57 EST 2008


Michael ODonnell writes:

> Of course, synchronization-wise things get interesting as soon
> as any job takes longer than the hourly interval because the next
> hour's queue-runner has to know not to interfere with the one that's
> still active.  A lock-file should be enough to handle that, though.
> 
> It's a SMOP - here's the whole thing in Perl:
> 
>    $_()%@queue#=.;time~[HiMom]%^$!!__chomp<backup>|\+{&};

Interesting Perl-fu.  I probably would have done it this way though:

perl -e 'use LockFile::Simple qw(lock unlock); 

         # we require >=2 args
         # 1st arg is lockfile
         # 2nd...Nth are executed when we have the lock
         die "usage:  lock lockfile arg1 arg2\n" if (scalar(@ARGV) < 2);

         $lockfile=shift;
         lock($lockfile) && system(@ARGV); 
         unlock($lockfile)' \
    /tmp/my-lockfile \
    /bin/sh -c 'sleep 10 ; echo elvis has left the building'

Kind regards,

--kevin
-- 
GnuPG ID: B280F24E                Don't you know there ain't no devil,
alumni.unh.edu!kdc                there's just God when he's drunk?
http://kdc-blog.blogspot.com/     -- Tom Waits


More information about the gnhlug-discuss mailing list