Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
lockfile [options] filenames
Create semaphore file(s), used to limit access to a file. When lockfile fails to create some of the specified files, it pauses for eight seconds and retries the last one on which it failed. The command processes flags as they are encountered (i.e., a flag that is specified after a file will not affect that file). This command is most often used by scripts and applications as a way to avoid multiple users changing the same file at once.
Number of seconds lockfile waits before retrying after a failed creation attempt. Default is 8.
Invert return value. Useful in shell scripts.
Time (in seconds) after a lockfile was last modified at which it will be removed by force. See also -s.
If the permissions on the system mail spool directory allow it or if lockfile is suitably setgid, lockfile can lock and unlock your system mailbox with the options -ml and -mu, respectively.
Stop trying to create files after this many retries. The default is -1 (never stop trying). When giving up, remove all created files.
After a lockfile has been removed by force (see -l), a suspension of 16 seconds takes place by default. (This is intended to prevent the inadvertent immediate removal of any lockfile newly created by another program.) Use -s to change the default suspend time.