title: flock permission denied bash
body: <p>I have written a little test script to prevent running my script simultaneously with flock:</p>
  
  <pre><code>#!/bin/bash
  
  scriptname=$(basename $0)
  lock="/var/run/${scriptname}"
  umask 0002
  
  exec 200&gt;$lock
  flock -n 200 || exit 1
  
  ## The code:
  sleep 60
  echo "Hello world"
  </code></pre>
  
  <p>When I run the script with my user and try to run the script with another user I got following error message with the lock file.</p>
  
  <pre><code>/var/run/test.lock: Permission denied
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Kind regards,
  Andreas</p>