I have a script using the following command to remove a folder:ssh -q root@hostname sh -c 'rm -rf /opt/jetty/'Most of the times it works fine, but occasionally I get this message:rm: cannot remove `/opt/jetty': Directory not emptyThe only suspicious point is the folder to delete contains a lock file which is being used by shell command flock to acquire file lock. But I tried to remove the folder manually when the file was even being locked by flock, it get succeeded.update:The environment is Linux# uname -aLinux XXX 2.6.32-504.8.1.el6.x86_64 #1 SMP Fri Dec 19 12:09:25 EST 2014 x86_64 x86_64 x86_64 GNU/Linuxrm didn't alias to anything, the out put of rm:# rmrm: missing operandTry `rm --help' for more information.I have a service script to start Jetty which creates a file lock inside the folder. Some snippet as shown below:JETTY_LOCK=/opt/jetty/jetty_lockstart(){    #open file descriptor and acquire lock    exec 200>$JETTY_LOCK    flock -x -n 200 || { exec 200>&-;echo 'jetty is being started by another process.'; sleep 5; exit 0; }    ...    cd /opt/jetty/   ...    echo $!>&200    fi    flock -u 200  #release lock    exec 200>&-   #close file descriptor}update:After the error reproduced, I found only jetty_lock file was still remaining int /opt/jetty, does that mean flock stops file lock from deleting? I cannot provide more details because I don't know when will it happen the next time...
rm -rf: cannot remove `/opt/jetty': Directory not empty
shell script;filesystems;directory;rm