Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 27th, 2001, 03:30 AM
focus focus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Luxembourg
Posts: 87 focus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 55 sec
Reputation Power: 9
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

Reply With Quote
  #2  
Old March 27th, 2001, 08:26 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 11
Send a message via Yahoo to jdk
Question What you exactly need ?

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

Reply With Quote
  #3  
Old March 27th, 2001, 08:37 AM
focus focus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Luxembourg
Posts: 87 focus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 55 sec
Reputation Power: 9
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.......

Reply With Quote
  #4  
Old March 27th, 2001, 09:10 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 11
Send a message via Yahoo to jdk
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

Reply With Quote
  #5  
Old March 29th, 2001, 11:07 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > how to repeat a script run every minute


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT