#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15

    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);
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15

    Thumbs up


    How about putting that program inside a crontab??
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15

    Question


    dwarf,

    How to use the crontab command? Could u mind to teach me? Thanks!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    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/ne...ix/cron-1.html and read it.

    HTH.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    0
    Rep Power
    0

    Lightbulb



    I have written a simple script 2 weeks ago.
    I don't know if this could help.
    go to.http://www.salalah.f2s.com/en/cacher.php3



    [Edited by Khaled on 01-16-2001 at 02:50 PM]
  10. #6
  11. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15

    Angry


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

    the script in crontab:
    ----------------------------------
    * * * * * root perl /home/file1.pl
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15

    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??
  14. #8
  15. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15

    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
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15

    Thumbs up


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

IMN logo majestic logo threadwatch logo seochat tools logo