Post History
Suppose I have some hypothetical CLI program. It is important that only one instance of this program runs at any given time. When multiple instances run concurrently, bad things happen. Normally, ...
#1: Initial revision
Forbid concurrent runs of a process
Suppose I have some hypothetical CLI program. It is important that only one instance of this program runs at any given time. When multiple instances run concurrently, bad things happen. Normally, the developer of the program should add some mechanism to prevent this, but let's say this one didn't and I'm not able to develop such a feature myself. The problem is vulnerable to the unexpected concurrent runs issue if no steps are taken by the user (me). Is there a general mechanism in Linux for saying "don't let more than 1 instance of this program to run from now on"? I am expecting that there are actual many ways to do it. I suggest posting one method per answer, and let the voters decide how to sort them.