[Sunhelp] Locking a Process
Jonathan Vafai
jon.vafai at nyu.edu
Sat Jun 26 21:26:07 CDT 1999
On Sat, Jun 26, 1999 at 09:24:36PM -0400, Trevor Chandler wrote:
> Hello all,
>
> I have a shell script that I need to ensure can have ONLY ONE
> instance of the shell script running at any given time. Does
> anyone know of a UNIX mechanism that can be implemented to
> accomplish this?
>
> Thanks to everyone who takes the time to read and respond to my
> question.
The way I do this (and I think this is pretty standard)
is to create a file (usually with the process ID in it)
and check if it exists before running. When the script
is done, delete the file. Services such as httpd, sshd,
and many other do this.
Jon
More information about the SunHELP
mailing list