1SHLOCK(1) General Commands Manual SHLOCK(1)
2
3
4
6 shlock - create lock files for use in shell scripts
7
9 shlock -p pid -f name [ -b ] [ -u ] [ -c ]
10
12 Shlock tries to create a lock file named name and write the process ID
13 pid into it. If the file already exists, shlock will read the process
14 ID from the file and test to see if the process is currently running.
15 If the process exists, then the file will not be created.
16
17 Shlock exits with a zero status if it was able to create the lock file,
18 or non-zero if the file refers to currently-active process.
19
21 -b Process IDs are normally read and written in ASCII. If the
22 ``-b'' flag is used, then they will be written as a binary int.
23 For compatibility with other systems, the ``-u'' flag is
24 accepted as a synonym for ``-b'' since binary locks are used by
25 many UUCP packages.
26
27 -c If the ``-c'' flag is used, then shlock will not create a lock
28 file, but will instead use the file to see if the lock is held
29 by another program. If the lock is valid, the program will exit
30 with a non-zero status; if the lock is not valid (i.e., invoking
31 shlock without the flag would have succeeded), then the program
32 will exit with a zero status.
33
35 The following example shows how shlock would be used within a shell
36 script:
37 LOCK=<pathrun in inn.conf>/LOCK.send
38 trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
39 if shlock -p $$ -f ${LOCK} ; then
40 # Do appropriate work
41 else
42 echo Locked by `cat ${LOCK}`
43 fi
44
46 shlock assumes that it will not be used in an environment with multiple
47 locks/unlocks in a short time (due to a race condition). That is,
48 shlock is intended for daily or hourly jobs.
49
51 Written by Rich $alz <rsalz@uunet.uu.net> after a description of HDB
52 UUCP locking given by Peter Honeyman. This is revision 5794, dated
53 2002-10-01.
54
56 inn.conf(5)
57
58
59
60 SHLOCK(1)