kill -p 参数

xiaoxiao2021-02-28  97

linux 提供了kill命令

man 之后发现可以这样使用kill,kill -p 进程名字,打印进程名字对应的pid

举例:

kill -p nginx 可以打印nginx的pid

可是输入了kill -p nginx 提示的却是invalid signal specification

原因是:在shell里面调用kill,默认调用的是shell的内置函数kill,内置函数不包含-p参数,所以有该错误提示

正确的输入应该是  /usr/bin/kill  -p nginx  

也可以加-a参数,代表所有用户

仔细查看kill的man 文档,可以发现这样一句话:

Most modern shells have a builtin kill function, with a usage rather similar to that of the command described here.  The '-a' and '-p' options, and the  possibility to specify processes by command name are a local extension.

在shell里面type kill可以看到kill是shell的内置函数

转载请注明原文地址: https://www.6miu.com/read-48667.html

最新回复(0)