ormaaj 1340794499 learn http://mywiki.wooledge.org/BashFAQ/045 http://wiki.bash-hackers.org/howto/mutex lhunath 1375805693 forget lhunath 1375805698 learn A mutual exclusion lock ensures your script can only be running once. mkdir "$lockdir" || exit 1; ...; rm -rf "$lockdir" # Another option: exec 9>> "$lockfile"; { [[ $(fuser -f "$lockfile") == $$ ]] || exit 1; } 2>&- 9>&- # (fuser also works read-only and cleanup is implicit) See http://mywiki.wooledge.org/BashFAQ/045 http://wiki.bash-hackers.org/howto/mutex lhunath 1375806115 forget lhunath 1375806197 learn A mutual exclusion lock ensures your script can only be running once. mkdir "$lockdir" || exit 1; trap 'rm -rf "$lockdir"' EXIT # Another option: exec 9>> "$lockfile" && [[ $({ fuser -f "$lockfile"; } 2>&- 9>&-) == $$ ]] || exit 1 # (fuser also works read-only and cleanup is implicit) See http://mywiki.wooledge.org/BashFAQ/045 http://wiki.bash-hackers.org/howto/mutex lhunath 1375806306 forget lhunath 1375806344 learn A mutual exclusion lock ensures your script can only be running once. mkdir "$lockdir" && trap 'rm -rf "$lockdir"' EXIT || exit # Another option: exec 9>> "$lockfile" && [[ $({ fuser -f "$lockfile"; } 2>&- 9>&-) == $$ ]] || exit # (fuser also works read-only and cleanup is implicit) See http://mywiki.wooledge.org/BashFAQ/045 http://wiki.bash-hackers.org/howto/mutex