我正在使用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'); 对此有什么想法吗?提亚
发布于 2019-07-29 21:59:17
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"
}https://stackoverflow.com/questions/57254968
复制相似问题