Skip to main content
3 of 3
No need to use non-standard syntax here.
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

There is no flock or similar command for Solaris. If I want to do simple locking I use mkdir as it's a atomic operation and avoids potential race conditions with the usual check file exists/touch combination.

if ! mkdir /tmp/lockdir >/dev/null 2>&1
then
    echo >&2 "Lock exists exiting"
    exit 1
fi
user591