1DOTLOCKFILE(1)                 Cistron Utilities                DOTLOCKFILE(1)
2
3
4

NAME

6       dotlockfile - Utility to manage lockfiles
7

SYNOPSIS

9       dotlockfile -l [-r retries] [-i interval] [-p] [-q] <-m | lockfile>
10       dotlockfile  -l  [-r  retries]  [-i interval] [-p] [-q] <-m | lockfile>
11       [-P] cmd args ...
12       dotlockfile -u | -t
13

DESCRIPTION

15       dotlockfile is a command line utility to reliably create, test and  re‐
16       move  lockfiles.   It  creates  lockfiles  reliably  on  local  and NFS
17       filesystems, because the crucial steps of  testing  for  a  preexisting
18       lockfile  and  creating it are performed atomically by a single call to
19       link(2).  Manpage lockfile_create(3) describes the used algorithm.
20
21       dotlockfile is installed with attribute SETGID mail and thus  can  also
22       be used to lock and unlock mailboxes even if the mailspool directory is
23       only writable by group mail.
24
25       The name dotlockfile comes from the way mailboxes are  locked  for  up‐
26       dates  on  a  lot of UNIX systems.  A lockfile is created with the same
27       filename as the mailbox but with the string ".lock" appended.
28
29       The names dotlock and lockfile were already taken – hence the name dot‐
30       lockfile :).
31

OPTIONS

33       -l     Create  a  lockfile  if  no preexisting valid lockfile is found,
34              else wait and retry according to option -r.  Retry interval  can
35              be  explicitly  set with option -i.  This option (-l) is the de‐
36              fault, so it can be left off.
37
38              A lockfile is treated as valid,
39              •  if it holds the process-id of a running process,
40              •  or if it does not hold any process-id and  has  been  touched
41              less than 5 minutes ago (timestamp is younger than 5 minutes).
42
43       -r retries
44              The  number  of times dotlockfile retries to acquire the lock if
45              it failed the first time before giving up.   The  initial  sleep
46              after  failing  to  acquire  the  lock is 5 seconds.  After each
47              retry the sleep interval is increased incrementally by 5 seconds
48              up  to  a maximum sleep of 60 seconds between tries unless over‐
49              ridden by -i.  The default number of retries is 5.  To try  only
50              once, use "-r 0".  To try indefinitely, use "-r -1".
51
52       -i interval
53              Sets a consistent retry interval.
54
55       -u     Remove a lockfile.
56
57       -t     Touch  an  existing lockfile (update the timestamp).  Useful for
58              lockfiles on NFS filesystems.  For lockfiles on  local  filesys‐
59              tems the -p option is preferable.
60
61       -p     Write  the process-id of the calling process (or dotlockfile it‐
62              self if a command is executed) into  the  lockfile.   Also  when
63              testing  for  an  existing  lockfile, check the contents for the
64              process-id of a running process to verify  if  the  lockfile  is
65              still  valid.   Obviously  useful  only  for  lockfiles on local
66              filesystems.
67
68       -m     Lock or unlock the current users mailbox.  The path to the mail‐
69              box   is   the   default  system  mailspool  directory  (usually
70              /var/mail) with the username as gotten from getpwuid() appended.
71              If  the environment variable $MAIL is set, that is used instead.
72              Then the string ".lock" is appended to get the name of  the  ac‐
73              tual lockfile.
74
75       -q     Don't  print  warnings  or  errors to the standard error output.
76              Used internally by liblockfile when it spawns dotlockfile  as  a
77              helper program.
78
79       -P     On  successful  "lock and spawn command", don't exit with status
80              zero, but pass through the exit value of the spawned command.
81
82       lockfile
83              The lockfile to be created or removed.  Must not be specified if
84              the -m option is given.
85
86       command argument ...
87              Create  lockfile, run the command , wait for it to exit, and re‐
88              move lockfile.
89

RETURN VALUE

91       Zero on success, and non-zero on failure.  When locking  (the  default,
92       or  with  the -l option) dotlockfile returns the same values as the li‐
93       brary function lockfile_create(3).  Unlocking a  non-existent  lockfile
94       is not an error.
95
96       Unless  the -P option was supplied, when a command is executed, the re‐
97       turn value does not correspond with that of the command that  was  run.
98       If locking and unlocking was successful, the exit status is zero.
99

NOTES

101       The  lockfile is created exactly as named on the command line.  The ex‐
102       tension ".lock" is not automatically appended.
103
104       This utility is a lot like the lockfile(1) utility included with  proc‐
105       mail,  and the mutt_dotlock(1) utility included with mutt.  However the
106       command-line arguments differ, and so does the return  status.   It  is
107       believed,  that  dotlockfile is the most flexible implementation, since
108       it automatically detects when it needs to  use  privileges  to  lock  a
109       mailbox, and does it safely.
110
111       The  above  mentioned  lockfile_create(3) manpage is present in the li‐
112       blockfile-dev package.
113

BUGS

115       None known.
116

SEE ALSO

118       lockfile_create(3), maillock(3)
119

AUTHOR

121       Miquel van Smoorenburg
122
123
124
125                               January 10, 2017                 DOTLOCKFILE(1)
Impressum