|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
I need to run a perl script every minute (forever). I'm told I should add something like "@now() + 1 minute" at the end of the script. Can anyone tell me what syntax applies? Thanks |
|
#2
|
||||
|
||||
|
hi friend,
what u exactly need to do ? is ur perl script a cgi application that is running off the webserver and giving some output to browser. or is it a standalone application.. the solution is easy for former case. in ur ouput to browser u write a refresh meta tag in html which will have ur script url in path. and set time to 1 min. so it will be called every 1 min . IF user browser is kept running. but i wonder if u need this kind of thing. anyhow give some more light on problem. thats it, jd
__________________
_____________________________ d.k.jariwala (JD) ~ simple thought, simple act ~ I blog @ http://jdk.phpkid.org |
|
#3
|
|||
|
|||
|
Hi jd
I need to have a mySQL table constantly updated in the background so that any browser calls for the data cause Perl to interrogate a current table, rather than update it every call. So I thought I'd set a cron to update it, then I was told I could do it with a perl script which repeats itself every minute using "internal" perl commands. It starts to look as though a cron would be the best solution....... |
|
#4
|
||||
|
||||
|
Didnt get u.
hi focus,
i didnt get wat u mean to say. u want to update mysql data , but whats the source ? and browser calls some perl script which fetches the data from mysql ? actually i still dont get wat ur exact requirement is. anyhow cron is handy if u have access to server. but updating every minute would load the server i may think. anyhow best of luck for solution. take care, jd |
|
#5
|
|||
|
|||
|
Code:
#!/usr/bin/perl
use DBI;
# Do dbi connect stuff here
my $pid = fork();
if($pid) {
print "Forked! Going into daemon mode!\n";
print "PID: $pid\n";
exit;
}
while(1) {
# Whatever routines you need here
sleep(60); # Sleep for a minute
}
This will create a daemon that runs constantly and does whatever you want every 60 seconds. This saves the overhead of having to compile the script every 60 seconds. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > how to repeat a script run every minute |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|