4 shlock \- create lock files for use in shell scripts
20 tries to create a lock file named
22 and write the process ID
25 If the file already exists,
27 will read the process ID from the file and test to see if the process
29 If the process exists, then the file will not be created.
32 exits with a zero status if it was able to create the lock file, or
33 non-zero if the file refers to currently-active process.
37 Process IDs are normally read and written in ASCII.
38 If the ``\-b'' flag is used, then they will be written as a binary
40 For compatibility with other systems, the ``\-u'' flag is accepted as
41 a synonym for ``\-b'' since binary locks are used by many UUCP packages.
44 If the ``\-c'' flag is used, then
46 will not create a lock file, but will instead use the file to see if
47 the lock is held by another program.
48 If the lock is valid, the program will exit with a non-zero status; if
49 the lock is not valid (i.e., invoking
51 without the flag would have succeeded), then the program will exit
54 The following example shows how
56 would be used within a shell script:
59 LOCK=<pathrun in inn.conf>/LOCK.send
60 trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
61 if shlock -p $$ -f ${LOCK} ; then
64 echo Locked by `cat ${LOCK}`
70 assumes that it will not be used in an environment with multiple
71 locks/unlocks in a short time (due to a race condition). That is,
73 is intended for daily or hourly jobs.
75 Written by Rich $alz <rsalz@uunet.uu.net> after a description of HDB UUCP
76 locking given by Peter Honeyman.
78 This is revision \\$3, dated \\$4.
80 .R$ $Id: shlock.1 5794 2002-10-01 23:31:53Z vinocur $