Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


flock_locking_from_script
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Last revision
flock_locking_from_script [2014/06/18 20:05] – created admin
Line 1: Line 1:
 +{{tag>[linux lock script]}} 
 +~~TOC~~ 
 +=====flock - locking from shell scripts===== 
 +Example 
 +<code># 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:</code>
flock_locking_from_script.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1