如何在MacO上的Terminal中找出正在执行的命令

时间:2022-02-25 16:06:14

After I run a shell script (which call a bunch a other scripts depend on conditions. which is too complicated to understand), I can execute a command 'gdbclient' at my MacOS terminal.

在我运行一个shell脚本(调用一堆其他脚本取决于条件。这太复杂而无法理解)之后,我可以在我的MacOS终端上执行命令'gdbclient'。

But when I do 'which gdbclient' and 'alias gdbclient', it shows nothing. Is there anyway for me to find out what 'gdbclient' is actually doing?

但当我做'哪个gdbclient'和'别名gdbclient'时,它什么都没显示。反正我有没有找到'gdbclient'实际上在做什么?

4 个解决方案

#1


You can open up another terminal window and type: ps

您可以打开另一个终端窗口并输入:ps

That will list all the running processes.

这将列出所有正在运行的进程。

If your script is running as a different user than the current one, you can use ps -ef to list all running processes.

如果您的脚本以与当前用户不同的用户身份运行,则可以使用ps -ef列出所有正在运行的进程。

If you know the PID of the process that ran your script, you can find all child processes via parent PID using ps -f | grep [pid]

如果您知道运行脚本的进程的PID,则可以使用ps -f |通过父PID查找所有子进程grep [pid]

#2


You can use the Activity Monitor to check things out pretty thoroughly. To get the right privileges to see everything going on you can do:

您可以使用活动监视器来彻底检查问题。要获得正确的权限,您可以执行以下操作:

sudo open /Applications/Utilities/Activity\ Monitor.app/

#3


Dtrace can give you some helpful information: dtrace

Dtrace可以为您提供一些有用的信息:dtrace

#4


to find process 'gdbclient':

找到进程'gdbclient':

ps aux | grep gdbclient

That wont tell you what it's "doing" but that it's running

那不会告诉你它在做什么,但它正在运行

#1


You can open up another terminal window and type: ps

您可以打开另一个终端窗口并输入:ps

That will list all the running processes.

这将列出所有正在运行的进程。

If your script is running as a different user than the current one, you can use ps -ef to list all running processes.

如果您的脚本以与当前用户不同的用户身份运行,则可以使用ps -ef列出所有正在运行的进程。

If you know the PID of the process that ran your script, you can find all child processes via parent PID using ps -f | grep [pid]

如果您知道运行脚本的进程的PID,则可以使用ps -f |通过父PID查找所有子进程grep [pid]

#2


You can use the Activity Monitor to check things out pretty thoroughly. To get the right privileges to see everything going on you can do:

您可以使用活动监视器来彻底检查问题。要获得正确的权限,您可以执行以下操作:

sudo open /Applications/Utilities/Activity\ Monitor.app/

#3


Dtrace can give you some helpful information: dtrace

Dtrace可以为您提供一些有用的信息:dtrace

#4


to find process 'gdbclient':

找到进程'gdbclient':

ps aux | grep gdbclient

That wont tell you what it's "doing" but that it's running

那不会告诉你它在做什么,但它正在运行