while ( true ) { $jobs = \DB::select( '*' )->from( 'jobs' )->execute(); sleep( 1 ); foreach ( $jobs as $job ) { $pid = pcntl_fork(); if ( !$pid ) { //do something. exit( $job->id ); } } while ( pcntl_waitpid( 0, $status ) != -1 ) { $status = pcntl_wexitstatus( $status ); echo "Child $status completed\n"; } }
It looks like you're new here. If you want to get involved, click one of these buttons!