SunQuest
           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:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old January 16th, 2001, 01:44 AM
RayRay RayRay is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Hong Kong
Posts: 71 RayRay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 50 sec
Reputation Power: 9
Unhappy

I need to do a job in server every 1 mintue, so I write a perl script to this job. Thus, I use the command while() and sleep() in my program, but the server need many... memory to do it. How can I solve this problem?


my perl script:
------------------------------------

use Mysql;

$dbh=Mysql->Connect($sql_host,$sql_db,$sql_user,$sql_pass);

while (1) {

$result=$dbh->Query("select * from table");
$count=$result->numfields;

for ($i=0;$i<$count;$i++) {
print $data[$i],"t";
}
print "n";
sleep(60);
}
exit(0);

Reply With Quote
  #2  
Old January 16th, 2001, 03:18 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Thumbs up

How about putting that program inside a crontab??

Reply With Quote
  #3  
Old January 16th, 2001, 03:36 AM
RayRay RayRay is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Hong Kong
Posts: 71 RayRay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 50 sec
Reputation Power: 9
Question

dwarf,

How to use the crontab command? Could u mind to teach me? Thanks!

Reply With Quote
  #4  
Old January 16th, 2001, 10:14 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
its no big deal. Under all UNIX systems, there as a damon that is called crontab, which is used to execute a certain command in some period of time which is given to it. I cannot tell you all there is about crontab (too long for this post), but there are several resources you can use to learn something about it:
1) you can type man cron from the shell prompt (or man cron | col -b > cron.txt if you want to print it)
2) Go to http://www.attrition.org/security/n...nix/cron-1.html and read it.

HTH.

Reply With Quote
  #5  
Old January 16th, 2001, 03:47 PM
Khaled Khaled is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 0 Khaled User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb


I have written a simple script 2 weeks ago.
I don't know if this could help.
go to.URL



[Edited by Khaled on 01-16-2001 at 02:50 PM]

Reply With Quote
  #6  
Old January 17th, 2001, 04:57 AM
RayRay RayRay is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Hong Kong
Posts: 71 RayRay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 50 sec
Reputation Power: 9
Angry

I try to use the crontab command, but it doesn't work.

the script in crontab:
----------------------------------
* * * * * root perl /home/file1.pl

Reply With Quote
  #7  
Old January 17th, 2001, 06:53 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Question

Hm, thats strange. Could you post the code of your script, or maybe some error messages. What does crontab tell you?? Or it simply doesn't execute the script??

Reply With Quote
  #8  
Old January 18th, 2001, 02:09 AM
RayRay RayRay is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Hong Kong
Posts: 71 RayRay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 50 sec
Reputation Power: 9
Talking

I already solve it. It is no need to use the "root" in the script.

wrong:
* * * * * root perl /home/file1.pl

right:
* * * * * perl /home/file1.pl

Reply With Quote
  #9  
Old January 18th, 2001, 02:54 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Thumbs up

Well, its nice to see you worked out your problem...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > a job in server every 1 mintue.


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 2 hosted by Hostway