CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Continuously running cron type system

 



Warren Bell
Deleted

Mar 4, 2001, 9:41 PM

Post #1 of 4 (635 views)
Continuously running cron type system Can't Post

I'm going to be writing a web interface to interact with some home automation software. What I want to do is have the Perl script continuously run and check a text file for scheduled events every minute. If an events time matches the system time it will run that event and keep continuously checking. I know there might be a lot to this but can anyone tell me the basic way I can go about doing this? And will this take a lot of system resources since it will be running all the time?

I'm going to be running this on Linux and can probably use cron but I think it might be easier for me to do this with straight Perl.



sleuth
Enthusiast / Moderator

Mar 4, 2001, 10:23 PM

Post #2 of 4 (633 views)
Re: Continuously running cron type system [In reply to] Can't Post

 
A tip I can give you is using cron to re-run your script every minute is putting a load on the server, rather than writing a daemon. If you can load a daemon on your server, if you are allowed, then I'd do that, in the advanced forum I have a small example of a daemon in my question. If you put your code to check the data base instead of where it prints it would work, except you'd want it to sleep for 60 seconds instead of whatever I had.

Much like the mail daemon on a server your daemon would have to be initiated when the server starts up. I got as far as running the daemon locally for testing then dropped it, I know that through certain admin panels in linux systems you can get it to do just that but I don't remember how. I killed my linux box a while ago out of frustration, I'm going to setup another one though.

Good Luck with that, I'd actually try and get some information about loading your script into the system so it starts with the server from your hosting company.

Tony



Warren Bell
Deleted

Mar 4, 2001, 11:05 PM

Post #3 of 4 (630 views)
Re: Continuously running cron type system [In reply to] Can't Post

Thanks, I'll check out your post.

As far as starting the script on boot and running daemons, It's a home server so there's no problem there :)

If anyone has any other info I'd appreciate it.



Warren Bell
Deleted

Mar 6, 2001, 12:45 PM

Post #4 of 4 (621 views)
Re: Continuously running cron type system [In reply to] Can't Post

Ok, I looked around and found I can use this to check for somthing every minute, execute somthing if a condition exists and continue on. This will let my script run all the time continuously checking. This is very basic, is it the best way to do this? I'm looking for somthing that will take hardly any resources..

#!/usr/bin/perl

while (1) {

$date = `date`;
if ($date =~ /20:30/) {
`do somthing`;
}

sleep 60;

}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives