[CentOS-mirror] 4.3 free drive space

Matthew Miller mattdm at mattdm.org
Sat Mar 18 11:05:29 UTC 2006


On Sat, Mar 18, 2006 at 12:44:55AM -0500, Zenon Panoussis wrote:
> > if [ -f /some/path/lockfile ]
> > then
> > exit
> The downside of lockfiles is that if your script crashes they
> stay behind and keep blocking until you realise it and remove
> them manually. A somewhat better way to do this could be to

Not necessarily. Do something like this:

trap "rmdir ${LOCKFILE}" EXIT TERM INT QUIT

and it'll get removed no matter the reason your script quit.

It's better to use directories than regular files for lockfiles, because
you can use mkdir to both test for existence and create the lock if it isn't
there already.

It'd also be better to trap each exit individually and log a separate
message for each....

-- 
Matthew Miller           mattdm at mattdm.org          <http://mattdm.org/>
Boston University Linux      ------>              <http://linux.bu.edu/>



More information about the CentOS-mirror mailing list