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. ...
- 12-31-2009 #1Just 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.
- 12-31-2009 #2
I'm a huge fan of use Proc::Fork; myself.
Hope this will help =)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)
}
};


Reply With Quote