Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)

by merlyn (Sage)
on Dec 02, 2009 at 19:57 UTC ( #810669=note: print w/ replies, xml ) Need Help??


in reply to RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)

You need the Highlander solution ("there can be only one").

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


Comment on Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)
Re^2: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)
by djp (Hermit) on Dec 03, 2009 at 23:05 UTC
    ++merlyn. I followed the highlander link and spotted this in the code listing at line 4:
    open HIGHLANDER, ">>/tmp/renew.cgi.highlander" or die "Cannot open hig +hlander: $!";
    I never (ever!) thought I would have cause to correct merlyn, but this contains one of my pet peeves, error messages which don't tell you what's happening, e.g.
    Cannot open highlander: No disk space at ... Cannot open highlander: Permission denied at ...
    Analyzing any problem requires the support person to read the code to discover the problem filename. They don't want to do that (and in a compiled language they can't), they just want to fix the problem. Suggest this:
    my $highlander = '/tmp/renew.cgi.highlander'; open HIGHLANDER, ">>$highlander" or die "Cannot open $highlander: $!";
    Cannot open /tmp/renew.cgi.highlander: No disk space at ... Cannot open /tmp/renew.cgi.highlander: Permission denied at ...
      That code was written pretty early. The suggestion you're making is one I started preaching a bit later.

      -- Randal L. Schwartz, Perl hacker

      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

        Excellent, I didn't think I could put one over you.

      Wouldn't it be nice if the $! error message came with the filename already embedded?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        How could that be done? $! is associated with errno or equivalent, but not necessarily with a file.
      autodie both adds the file name to the error message and saves you from having to do the or die ...; dance:
      # open.pl use strict; use warnings; use autodie; open HIGHLANDER, ">>/root/renew.cgi.highlander";
      when run (as non a root user), gives:
      +% perl open.pl Can't open '>>/root/renew.cgi.highlander' for appending: 'Permission d +enied' at open.pl line 6 +%

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://810669]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2014-07-25 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (172 votes), past polls