From: Mike Kasick Date: 2008-05-29T07:35:22+09:00 Subject: Re: Ensuring only one instance of a script is running On Wed, May 21, 2008 at 01:25:08PM +0900, Daniel Berger wrote: > The first run will work, but trying to start the program up again will > fail instantly because of the lock on DATA. Cute trick. However, I wouldn't recommend it's use in any distributed code. flocks are intended to serve a purpose other than what's achieved as a side effect here, and although it's generally safe, the behavior is unknown at best if the script file resides in a remote file system like NFS. For example, in Linux versions prior to 2.6.12 flocks are local only, so this would have the intended effect. However, in Linux versions 2.6.12 and newer, flocks are emulated by POSIX locks, which should result in only a single instance running across a set of machines attempting to run the same script located in an NFS share.