[GRLUG] using flock

Eric Beversluis ebever at researchintegration.org
Tue Dec 24 09:31:47 EST 2013


Thanks.
So since the script started and then exits, cron assumes it has run and
just waits till the next time?

On Tue, 2013-12-24 at 09:25 -0500, Michael Glaske wrote:
> Pretty easy to implement in bash or sh..  The only problem is, if you
> Crtl-C out of it, you'll have to manually remove the lock file.
> 
> 
> if [ -f /var/run/script.lock ]; then
>      print "Already running..  Exiting"
>      exit 1
> fi
> 
> 
> date > /var/run/script.lock
> 
> 
> # put your script here
> 
> 
> # at the end
> rm -f /var/run/script.lock
> 
> 
> On Tue, Dec 24, 2013 at 9:17 AM, Eric Beversluis
> <ebever at researchintegration.org> wrote:
>         I've got a backup program on a server that includes a
>         mysqldump once a
>         day which overwrites the existing sysmyqldump.sql. The script
>         also does
>         rsync (of zarafa-backup, the mysqldump, and /var/lib/zarafa
>         (the zarafa
>         attachments file) to an external hard drive. Once a month is
>         also copies
>         the sysmysqldump.sql that's on the external HDD to a file with
>         that
>         day's date attached.
>         
>         The cron is set to run every hour. Right now, mysqldump is
>         finishing at
>         40 min past the hour (00:40), so I think that when it also
>         tries to make
>         the copy on the 1st of the month it will run over into the
>         next hour.
>         
>         As I understand it, the thing to do to prevent the script
>         starting over
>         before the old one finishes is to use 'flock.'
>         
>         My question is this: How does cron respond if flock prevents
>         the script
>         from starting at 01:00? Does it start it when the flock is
>         freed or just
>         skip that cycle or what?
>         
>         Thanks.
>         
>         _______________________________________________
>         grlug mailing list
>         grlug at grlug.org
>         http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> 
> 
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug




More information about the grlug mailing list