By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

Setting up an alarm scheduler?

P: 27
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.

Apr 8 '08 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 4,059
You could use the sleep() function to make your script wait for one minute:


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.
Apr 8 '08 #2

P: 27

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?

Apr 8 '08 #3

Expert 2.5K+
P: 4,059
This will never stop running, you will have to manually terminate it with kill or something else:

Expand|Select|Wrap|Line Numbers
  1. while (1) {
  2.     $|++; # flush the buffers - might not be necessary
  3.     print "Hello World\n";
  4.     sleep(5);
  5.     next;
  6. }
I don't think you would not use an alarm for this type of looping.
Apr 8 '08 #4

P: 27
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.

Apr 8 '08 #5

Expert 2.5K+
P: 4,059
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".
Apr 8 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.