Semaphore

Hi,

I am looking to use a semaphore for the first time in one of my scripts. I am just wondering if there are any simple examples or tutorials around?

I am a beginner so the simpler the better :slight_smile:

Thanks

-Jaken

Shell scripts do not have a per se semaphore facility. There are several ways to communicate with other scripts, mostly via files. Languages like perl do have semaphores.

I managed to grab a semaphore implementation in ksh originally written by
Ed Schaefer and John Spurgeon for UNIX Review in 2004. The original has dissappeared but my slightly fixed copy is available at:

http://www.cs.umb.edu/~rouilj/\#Semaphore

In addition to per user seamphores it also supports a queing mechanism to help prevent starvation.

The only current issue with it is that it works only on a single machine,
I have a plan on how to make it work across multiple machines, but that's not implemented yet.

-- rouilj