Find the answer to your Linux question:
Results 1 to 2 of 2
I have a perl script which updates its result to a database. This has to be run daily. But my script takes more than 1 day to complete my task. ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    5

    Perl Script

    I have a perl script which updates its result to a database. This has to be run daily.

    But my script takes more than 1 day to complete my task. Hence, I was thinking about creating multiple threads by using fork() command.

    The sequence of database update doesnt matter, so I think forking would help speed up.

    Could someone give me advice on this? And some pointers would be appreciated too.

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    I'm a huge fan of use Proc::Fork; myself.

    use Proc::Fork;

    run_fork {
    child {
    # child code goes here.
    }
    parent {
    my $child_pid = shift;
    # parent code goes here.
    waitpid $child_pid, 0;
    }
    retry {
    my $attempts = shift;
    # what to do if if fork() fails:
    # return true to try again, false to abort
    return if $attempts > 5;
    sleep 1, return 1;
    }
    error {
    # Error-handling code goes here
    # (fork() failed and the retry block returned false)
    }
    };
    Hope this will help =)
    New Users, please read this..
    Google first, then ask..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...