--- run-crons.stock 2014-11-24 16:45:17.822842446 +0100 +++ run-crons.n 2014-11-24 16:46:39.554102904 +0100 @@ -37,7 +37,8 @@ # Make sure we're not running multiple instances at once. # Try twice to lock, otherwise give up. -for ((i = 0; i < 2; i = i + 1)); do +i=0 +while [ "$i" -lt 2 ]; do ln -sn $$ ${LOCKFILE} 2>/dev/null && break # lock failed, check for a running process. @@ -54,6 +55,7 @@ else rm -f ${LOCKFILE} fi + i=$(($i+1)) done # Check to make sure locking was successful