Setting up an alarm scheduler?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bdbeames
    New Member
    • Jun 2007
    • 27

    Setting up an alarm scheduler?

    I have procedure that I would like to run in perl that checks a data feed that I have running. I wrote the code to checks if the feed is up, now I would like to create an alarm that will use this code and check the feed every minute. Nothing should happen if it is up, otherwise it will send me an email.

    I'm just a new to perl, could someone help me in setting up this alarm to run my code say every minute.

    Thanks
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    You could use the sleep() function to make your script wait for one minute:

    sleep(60)

    besides that your question is confusing because you say you want an alarm but to me it seems like you do not need an alarm, you just need to slepp() then check the data feed and take appropriate action depending on the status of the feed.

    if you really want an alram use the alarm() function.

    Comment

    • bdbeames
      New Member
      • Jun 2007
      • 27

      #3
      ok

      I guess I sleep would work too.

      I've been having trouble getting them to do what I want.

      could you give me an example with sleep and alarm that just prints hello world every 5 seconds?

      thanks

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        This will never stop running, you will have to manually terminate it with kill or something else:

        Code:
        while (1) {
            $|++; # flush the buffers - might not be necessary
            print "Hello World\n";
            sleep(5);
            next;
        }
        I don't think you would not use an alarm for this type of looping.

        Comment

        • bdbeames
          New Member
          • Jun 2007
          • 27

          #5
          Thanks, that is what I am looking for. I want this to always be running. This is one of those time where an infinite loop can be of use. My thinking on alarm was every minute when the alarm goes off I would run my sub, sleep should work the same.

          Thanks

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            hehehe... glad you understood my tortured statement:

            I don't think you would not use an alarm for this type of looping.
            of course I meant that you "would not use an alarm".

            Comment

            Working...