FLOCK(1) | General Commands Manual | FLOCK(1) |
flock
— Provide
locking API for shell scripts
flock |
[-dnosvx ] [-w
timeout]
file|directory
command [args
...] |
flock |
[-dnosvx ] [-w
timeout]
file|directory
-c command |
flock |
[-dnsuvx ] [-w
timeout] number |
The flock
utility provides
flock(2) access to the command
line or scripts. The first two forms lock the specified
file or directory while the
provided command is executed. If the path does not exist, then a file of
that name is created with mode 0600.
The third form can use an arbitrary file descriptor number that is provided from a shell script for example:
( flock -s 100 # commands to be executed under the lock ) 100> /path/to/lockfile
The following options are available:
-c
command-d
,
--debug
-n
,
--nb
, --nonblock
-o
,
--close
-s
,
--shared
-u
,
--unlock
-v
,
--verbose
-w
,
--wait
, --timeout
seconds-x
,
--exclusive
The flock
utility exits 0 on
success, and >0 if an error occurs.
An flock
utility appeared in
NetBSD 6.1.
October 4, 2019 | NetBSD 10.99 |