Parse PHP to execute scripts in parallel in multiple processes. Because php processes do not support multithreading, in some scenarios, you can use php to implement multiple processes to make up for this deficiency in order to facilitate and improve the performance. copy the code as follows :#! Usrbin because php processes do not support multithreading, in some scenarios, you can use php to implement multi-process to make up for this deficiency for convenience and performance improvement:
The code is as follows:
#! /Usr/bin/env php
$ Cmds = array (
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 'mobile', 1 ),
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 'mobile', 2 ),
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 'click', 1 ),
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 'click', 2 ),
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 1 ),
Array ('/apps/bin/launcher. php', 'charge/promotion_props_stat.php', 2)
);
Foreach ($ cmds as $ cmd ){
$ Pid = pcntl_fork ();
If ($ pid =-1) {// process creation failed
Die ('fork child process failure! ');
}
Else if ($ pid) {// processing logic of the parent process
Pcntl_wait ($ status, WNOHANG );
}
Else {// sub-process processing logic
Pcntl_exec ('/usr/local/bin/php', $ cmd );
}
}
The pipeline code is as follows :#! /Usr/bin /...