我正在使用cpulimit
,没有这样的问题:
cpulimit -l 60 -z -v php /path/to/file/file.php
但是我想在此调用中添加另一个参数,例如:
cpulimit -l 60 -z -v php /path/to/file/file.php id=0
并尝试使用getopt
获得其价值。
但是问题是,如果我尝试显示如下选项,我将得到空数组:
$options = getopt('acc');
对此有何想法?蒂亚
答案 0 :(得分:0)
getopt正在搜索标志,例如--id=2
,因此它将与cpulimit混合使用
只需使用argv和argc:
<?php
var_dump($argv);
结果:
cpulimit -l 60 -z -v php a.php id=2
Launching php a.php id=2 with limit 60
Throttling process 7588
8 CPUs detected.
Warning: Cannot change priority. Run as root or renice for best results.
Process 7588 detected
%CPU work quantum sleep quantum active rate
array(2) {
[0]=>
string(5) "a.php"
[1]=>
string(4) "id=2"
}