foreach my $mnt (@mounts) { $script="file_collections.pl -u $user -m $mnt"; my $pid = fork; if (not defined $pid) { die 'Could not fork child'; next; } if ($pid) { $forks++; Log ("Parent process PID ($$) starting Child pid: $pid for $mnt. \nNum of forked child processes: $forks\n"); } else { Log ("child PID ($$) --> executing \'$script\' \n"); exec ("$scr_loc/$script"); exit; } } for (my $i = 0; $i < $forks; $i++){ my $pid = wait(); Log ("$0 : $pid Completed\n"); } file_collections.pl Log ("Start Time \t\t: $datestring \n\n"); Log ("Finding the files for $user with uid $uidNum on $mount\n"); $path=$mount; $path=~s/\//_/g; $user_file = "$log_dir/$user$path.list"; $user_log_file = "$log_dir/$user$path.log"; find(\&findFiles, "$mount"); $datestring = getDateTime(); Log ("Total number of files parsed on $mount = $count\n"); Log ("Saving the details to $user_file\n\n"); Log ("End Time \t\t: $datestring\n"); saveFile($user_file,@array_to_write); saveFile($user_log_file,@log); sub findFiles { my ($dev,$ino,$mode,$nlink,$uid,$gid,$file,$fstype); $file=$File::Find::name; $fstype=findFstype("$file"); $count++; (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($file)) && !($File::Find::prune |= ($dev != $File::Find::topdev)) && ($uid == "$uidNum") && push (@array_to_write,"$file:$uidNum:$gid:$mode:$fstype"); }