flock – manage locks from shell scripts

commandline session

$> 1
$flock 1
$ls
1
$echo 1 > 1
$cat 1
1
$ls -l
total 4
-rw-r--r-- 1 jeffrin jeffrin 2 Aug 11 18:24 1
$flock -n 1
$echo 1 > 1
$ls -l
total 4
-rw-r--r-- 1 jeffrin jeffrin 2 Aug 11 18:29 1
$1 /var/loc
local/ lock/
$1> /var/lock/mylock
$cat 1
1
$rm 1
$ls
$ls -l /var/lock/mylock
-rw-r--r-- 1 jeffrin jeffrin 0 Aug 11 18:30 /var/lock/mylock
$rm /var/lock/mylock
$ls
$1> /var/lock/mylock
$cat /var/lock/mylock
$cat /var/lock/mylock
$flock /var/lock/mylock ls
$ls
$cat /var/lock/mylock
$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s