问题描述
我同时打开了几个终端:
my_name console Jul 5 17:00 old 191
my_name ttys002 Jul 9 22:07 . 22109
my_name ttys004 Jul 10 07:17 00:04 23432
my_name ttys006 Jul 9 18:52 00:09 20880
my_name ttys007 Jul 9 18:53 00:09 20913
在其中两个终端中,我启动了一个包含迭代的 python 文件,以保持进程运行。
我想要所有正在运行的 python 进程的列表。
当我输入:$ ps -ef | grep python
或 $ps -elf | grep python
我只得到当前终端:
501 4342 3974 0 Mer08 ?? 8:59.94 /Users/my_name/.vscode/extensions/ms-python.python 2021.6.944021595/languageServer.0.5.59/Microsoft.Python.LanguageServer
501 23945 22110 0 7:26 ttys002 0:00.01 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox python
我怎样才能获得带有相关 python 进程的终端的完整列表?
我的最终目标是使用 python os.subprocess
和其他库终止 python 进程。