[clug-talk] file locking in bash?

Roy Souther roy at silicontao.com
Fri Jul 27 08:17:20 PDT 2007


I have no man pages for flock.

Could you give me an example of how to use that in bash?

On Fri, 2007-07-27 at 09:04 -0600, Mark Carlson wrote:

> On 7/27/07, Roy Souther <roy at silicontao.com> wrote:
> >
> >  Is there anyway to do file locking in a bash script? I need to remove the race hazard from a script that has multiple running instances per user, each trying to make changes to a text file. I need to get exclusive access to a file and make the other instances wait their turn.
> >
> >  Any ideas? Flock is supported by more advances script engines like Perl but flock seems to be beyond the ability of a simple shell like bash.
> 
> flock(1) is not acceptable?
> It uses the flock(2) sytem call, afaik.
> 
> -Mark
> 


Royce Souther
www.SiliconTao.com
Let Open Source help your business move beyond.

For security this message is digitally authenticated by GnuPG.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://clug.ca/pipermail/clug-talk_clug.ca/attachments/20070727/7aa88856/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://clug.ca/pipermail/clug-talk_clug.ca/attachments/20070727/7aa88856/attachment.bin 


More information about the clug-talk mailing list