【发布时间】:2018-09-15 07:21:51
【问题描述】:
TL;DR : 我想让命令在 /bin/bash 进程中运行(如果正在运行)。
我想要一个可以在 /bin/bash 进程中识别命令 /bin/bash 正在运行的脚本。试图在 /proc/[pid]/cmdline 中找到它,但它只显示 /bin/bash。
有没有办法做到这一点,或者我想知道的是不可能的。 :o
我问是因为当我运行ps -ef 时,一些进程(如 ssh)显示它们是如何运行的。
user 30410 30409 0 10:58 pts/0 00:00:00 ssh name@127.0.0.1 <-- here
ssh 命令完全打印出来了。
如果我执行命令ps -ef | grep "/bin/bash",我们可以看到相同的结果,它返回:
user 20080 4999 0 13:40 pts/9 00:00:00 grep /bin/bash <-- here
打印了 grep /bin/bash 命令。
但是,如果我运行像 while true; do echo "hello"; done 这样的 bash 循环
然后我做ps -ef | grep "while" 它什么也没返回!!!
【问题讨论】:
标签: linux process monitoring proc