Section: Cistron Utilities (1)
Updated: September 8, 2009Index
Return to Main Contents
dotlockfile - Utility to manage lockfiles
is a command line utility to reliably create, test and remove lockfiles.
It creates lockfiles
on local and NFS filesystems, because the crucial steps of testing for a
preexisting lockfile and creating it are performed
describes the used algorithm.
is installed with attribute
and thus can also be used to lock and unlock mailboxes
if the mailspool directory is only writable by group mail.
comes from the way mailboxes are locked for updates on a lot of UNIX systems.
A lockfile is created with the same filename as the mailbox but with the string
were already taken - hence the name dotlockfile :).
Create a lockfile if no preexisting valid lockfile is found, else wait and retry
according to option -r.
This option is the default.
A lockfile is treated as valid,
• if it holds the
of a running process,
• or if it does not hold any
and has been touched less than 5 minutes ago (timestamp is younger than
- -r retries
The number of times
retries to acquire the lock if it failed the first time before giving up.
The initial sleep after failing to acquire the lock is 5 seconds.
After each retry the sleep intervall is increased incrementally by 5 seconds
up to a maximum sleep of 60 seconds between tries.
The default number of retries is 5.
To try only once, use "-r 0".
To try indefinitely, use "-r -1".
Remove a lockfile.
Touch an existing lockfile (update the timestamp).
Useful for lockfiles on NFS filesystems.
For lockfiles on local filesystems the
option is preferable.
For debugging only: Check for the existence of a valid lockfile.
Note: Testing for a preexisting lockfile and writing of the lockfile
be done by the
"dotlockfile -l" or "dotlockfile -m" command, else the lockfile
creation cannot be reliable.
of the calling process into the lockfile.
Also when testing for an existing lockfile, check the contents for the
of a running process to verify if the lockfile is still valid.
Obviously useful only for lockfiles on local filesystems.
Lock or unlock the current users mailbox.
The path to the mailbox is the default system mailspool directory (usually
with the username as gotten from
If the environment variable
is set, that is used instead.
Then the string ".lock" is appended to get the name of the actual
The lockfile to be created or removed.
Must not be specified, if the -m option is in effect.
Zero on success, and non-zero on failure.
For the -c
option, sucess means that a valid lockfile is already present.
When locking (the default, or with the -l
returns the same values as the library function
Unlocking a non-existant lockfile is not an error.
The lockfile is created exactly as named on the command line.
The extension ".lock
" is not
This utility is a lot like the
utility included with
utility included with
However the command-line arguments differ, and so does the return status.
It is believed, that
is the most flexible implementation, since it automatically detects when it
needs to use priviliges to lock a mailbox, and does it safely.
The above mentioned
manpage is present in the
Miquel van Smoorenburg, firstname.lastname@example.org
- RETURN VALUE
- SEE ALSO