my $max_tasks=3; my $pid=fork(); if ($t_counter >= $max_tasks) { waitpid(-1,0); } $t_counter++; ... #### use strict; use Time::Out qw(timeout); use IPC::Open3; use Log::Log4perl qw(:easy); use Date::Format; use Config::General; use DBI;