Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Anyways, you should probably keep in mind, that you're about to write a fork bomb.

I see what you mean. Original code (not published here) had a check for that (see below) which is executed in the loop as launch(@ARGV). And if a Bash script should run periodically, we have a special Bash script to check if only one instance of a particular script is running. Although I must say, we are currently in the middle of porting of the Bash scripts to Perl.

sub launch { return if fork; exec @_; die "Couldn't exec"; } $SIG{CHLD} = 'IGNORE';

For Perl scripts, we use the Highlander function to eliminate the forks. This, however, could effectively kill the processes we want to run each second (n seconds), when one instance is running longer that the period.

And generally, we need n * second intervals. Some scripts run each second, others every 5 seconds. I have created this question to find a way to run the scripts every n seconds most accurately.

Beside of this, I guess, best way for really exact timing would be spawning the script, which now wait's within a spinlock for the current second to change.

This is interesting to me, but I am not a Perl guru (not even a pro programmer), therefore I’d like to ask you for more info what exactly is the spawning and the spinlock (although for this I should open another question I think). Thanks. :)

You also don't write, which platform you're on.

We run the scripts (and Perl) on CentOS exclusively. No need for portability.


In reply to Re^3: The most precise second (timer) by tukusejssirs
in thread The most precise second (timer) by tukusejssirs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-23 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found