脚本:$S='pgrep-ftest.php|wc-l';$U=trim(shell_exec($S));echo$U;为什么这个脚本的结果等于0有时是1?文件test.php没有运行。 最佳答案 问题是在执行命令时pgrep-ftest.php|wc-l,它有时会(取决于时间)出现在结果中。您可以根据aquestiononLinux&UnixSE防止这种情况发生使用以下语法:pgrep-f'[t]est.php'|wc-l括号中的部分基本上是说“找到字母t后跟est.php”,如果它正在运行,它会找到文件,但不会匹配当前执行的命令
文章目录问题背景pgrep指令help文档使用示例1.列出匹配进程的PID和进程名称(-l)(默认只能从进程名的子集字符串匹配,如果要使用完整进程名的子集字符串匹配,请加-f参数,下同)2.列出匹配进程的PID和完整的命令行(-a)3.统计匹配进程的数量(-c)4.使用完整的进程名称(包括参数)的子集进行匹配(-f)(如果pattern跨越进程命令与参数,需要用双引号括起来)★★★★★示例1示例25.不区分大小写进行匹配(-i)6.选择最近启动的进程(n)7.选择最早启动的进程(-o)8.仅匹配给定父进程的子进程(-P)9.通过控制终端进行匹配(-t)用途命令测试步骤示例10.通过有效ID进行
基本debian:wheezydocker镜像中没有pkill/pgrep#dockerrundebian:wheezypkillSystemerror:exec:"pkill":executablefilenotfoundin$PATH我不知道应该安装哪个软件包才能拥有这些工具#dockerrundebian:wheezycat/etc/apt/sources.listdebhttp://httpredir.debian.org/debianwheezymaindebhttp://httpredir.debian.org/debianwheezy-updatesmaindebhttp
基本debian:wheezydocker镜像中没有pkill/pgrep#dockerrundebian:wheezypkillSystemerror:exec:"pkill":executablefilenotfoundin$PATH我不知道应该安装哪个软件包才能拥有这些工具#dockerrundebian:wheezycat/etc/apt/sources.listdebhttp://httpredir.debian.org/debianwheezymaindebhttp://httpredir.debian.org/debianwheezy-updatesmaindebhttp