Locking a file to verify a single execution of a service. How reliable?
Posted
by Camilo Díaz
on Stack Overflow
See other posts from Stack Overflow
or by Camilo Díaz
Published on 2010-05-05T16:17:07Z
Indexed on
2010/05/05
16:48 UTC
Read the original article
Hit count: 232
Hello,
I am deploying a little service to an UNIX(AIX) system. I want to check if there is no active instance of that service running when starting it. How reliable is to implement that check like this?
- Try to acquire a lock on a file (w/
FileChannel
) - If succeeds, keep lock and continue execution
- If fails, exit and refuse to run the main body
I am aware of software like the Tanuki wrapper, however, I'm longing for a simpler(maybe not portable) solution.
Regarding PIDFILE(s): I want to avoid using them if possible, as I don't have administrative rights on the machine, neither knowledge in AIX's shell programming.
© Stack Overflow or respective owner