[Gllug] Single instance of a process - simple way

Henrik Bilar henrik at bilar.co.uk
Thu Jul 5 22:38:18 UTC 2007


You can use (file system) links to achieve locking, as the creation of a
lock is atomic. I wrote a little shell script wrapper for this once,
http://www.bilar.co.uk/wiki/index.php/Lock_manager_in_Bash

There's other ways as well, such as using semaphores (or lockf), but that
requires you to write (e.g.) a little c program to call the semaphore
operations. The link method should be portable(ish).


> Hi there
>
> I was going to ask if there was a simple shell lock utility where I
> can use to ensure single instance of a process is run.. but I found
> one as I was typing the mail:
>
> "chiark-utils -> with-lock-ex: a simple tool for acquiring a lockfile
> before running another program or script."
>
> Anyway, question is changed a little: now I am wondering if you know
> any other utilities like with-lock-ex. Maybe one with retries and
> time-outs for example.
>
> I have quite a few rsync cronjobs and I would like to run them as
> often as possible. But I don't want them to collide, in case one of
> the jobs is taking longer than the defined job frequency BTW, I am on
> Ubuntu-Server 7.04 Feisty Fawn.
>
> Cheers
>
> --Ziya
> --
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list