From fc5456dc786889af84b789b4ae4d23c85798a0ed Mon Sep 17 00:00:00 2001 From: lhark Date: Fri, 15 Feb 2019 18:36:41 -0500 Subject: [PATCH] [mailsync] Add SO credit for locking mechanism --- mailsync | 1 + 1 file changed, 1 insertion(+) diff --git a/mailsync b/mailsync index 1d1f411..3dfa0a6 100755 --- a/mailsync +++ b/mailsync @@ -5,6 +5,7 @@ maildir=~/mail mailboxes=$(find "$maildir" -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '%f\n') LOCKFILE="/tmp/.mailsync.$USER.lock" +# https://stackoverflow.com/questions/185451/quick-and-dirty-way-to-ensure-only-one-instance-of-a-shell-script-is-running-at # /!\ locking method is susceptible to race condition # Should be fine for cron job if [ -e "$LOCKFILE" ] && kill -0 "$(cat "$LOCKFILE")"; then