use DBI; while (1) { my $dbh = DBI->connect(); # Parent connecting # .. get a job list .. $dbh->disconnect(); # <-- NB! foreach my $job (@jobs) { my $pid = fork(); if (defined $pid) { if ($pid) { $children{$pid} = time; # This is the parent } else { child($job); # This is the child process } } else { logmsg "fork() failed: $!\n"; } } sleep 1; } sub child { my $job = shift; my $dbh = DBI->connect(); # Child connecting # .. do the job .. $dbh->disconnect(); exit; }