Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


flock_locking_from_script

This is an old revision of the document!


~~TOC~~

flock - locking from shell scripts

Example

# stop on errors
set -e
 
scriptname=$(basename $0)
pidfile="/var/run/${scriptname}"
 
# lock it
exec 200>$pidfile
flock -n 200 || exit 1
pid=$$
echo $pid 1>&200
 
## Your code:
flock_locking_from_script.1403121936.txt.gz · Last modified: 2014/06/18 20:05 by admin