I categorize semaphores by content and visibility. There's also location. Is the lock user-specific or group specific?
If the lock is user specific, then the semaphore needs to reside in the user's home directory, or else the username needs to be part of the semaphore filename.
If it's group or project related, the I put the semaphore in the local directory where the job is likely to be invoked. My group isn't very sophisticated so I've ceased making the semaphores hidden. (E.g., I use somehthing like jobname.semaphore instead of .jobname_semaphore)
Technically, semaphores are empty and it's merely their presence that acts as switch to the script or program. I've found that sometimes it's useful to store variables and values in them from time to time.
In Bourne shell scripts (.sh) in testing for the semaphore, the -s in the expression will not detect a completely empty file. Better to use -f instead.
if [ -f jobname.semaphore ] ; then
echo "File/program locked. Try again later."
exit 0
fi
Visit