#/usr/bin/php $subdir) { if (!pcntl_fork()) { $starttime = time(); $cmd = "/usr/bin/rsync -rp --delete $subdir" . (is_dir($subdir) ? '/ ' : ' ') . '/mnt/emc' . $subdir . (is_dir($subdir) ? '/' : ''); print getmypid() . " START $subdir $cmd\n"; exec($cmd); print getmypid() . " FINISH $subdir " . (time() - $starttime) . "s\n"; exit; } ++$children; print "$children CHILDREN, RUNNING FOR " . gmdate('H:i:s', time() - PARENTSTART) . ", ". round(($key + 1) / count($dirlist) * 100, 2) . "% LAUNCHED\n"; while ($children >= (file_exists('/tmp/maxchildren') ? chop(file_get_contents('/tmp/maxchildren')) : 10)) { pcntl_wait($status); --$children; } } print getmypid() . " COMPLETE... Waiting for children to finish.\n"; while (--$children) if (pcntl_wait($status) == -1) exit; ?>