Re: Ensure only single application instance.



Cameron Laird wrote:
In article <dPZtk.60600$5p1.41655@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Uberman <bhood37@xxxxxxxxxxx> wrote:
On Fri, Aug 29, 2008 at 6:51 AM, Heston James <heston_james@xxxxxxxxxx> wrote:
Good afternoon all.

I have an application/script which is launched by crontab on a regular
basis. I need an effective and accurate way to ensure that only one instance
of the script is running at any one time.
You could create a named pipe in /tmp with a unique (static) name and
permissions that disallow any kind of read/write access. Then simply have
your script check for its existence when it starts. If it exists, then
another instance of your script is running, and just terminate. Make sure
your original instance removes the pipe when it exits.

I'll write an article on this subject this fall. The
essentials are:
A. There's no canonical answer; every apparent solution
has problems;
B. The suggestions offered you are certainly among the
popular ones;
C. My personal favorite is to open a (network) socket
server. For reasons I'll eventually explain, this
has particularly apt semantics under Unix.

Cameron,

I found this recipe (http://code.activestate.com/recipes/474070/) on ActiveState's site that had a working version of a single instance class for Windows that I've used quite successfully. Since I also work a lot Linux, I wrote and donated this version (http://code.activestate.com/recipes/546512/) for Linux that also seems to work well for me.

-Larry
.



Relevant Pages

  • Re: Ensure only single application instance.
    ... I have an application/script which is launched by crontab on a regular ... basis. ... of the script is running at any one time. ... I'll be left with a dead pidfile on ...
    (comp.lang.python)
  • Re: Ensure only single application instance.
    ... I have an application/script which is launched by crontab on a regular ... basis. ... You could create a named pipe in /tmp with a unique name and ... your script check for its existence when it starts. ...
    (comp.lang.python)
  • Re: Deleting files from /var/tmp
    ... > on a regular basis.this script must delete the files on a regular ... > the crontab? ... regular basis say every 15 minutes. ...
    (comp.unix.shell)
  • Deleting files from /var/tmp
    ... on a regular basis.this script must delete the files on a regular ... basis say every 15 minutes. ... My Os is sun solaris 8.How do I go about doing this and also add to ...
    (comp.unix.shell)
  • Re: Will Linux become as vulnerable as MS ??
    ... > beeing vulnerable to viruses. ... > that they know are executable, and execute intentionally. ... >> Linux, each distro is a little different, and even within the distro, ... > Since clicking on a script is easier than typing it's name, ...
    (comp.os.linux.security)