如何使用Mac Terminal的隐藏任务管理器查看后台进程
You’re closing a Terminal window, only to be told that doing so will terminate a running process. Which is confusing, because you didn’t know anything was still running at all.
您正在关闭“终端”窗口,但被告知这样做将终止正在运行的进程。 这令人困惑,因为您根本不知道任何东西还在运行。
There are all kinds of reasons an application might be running in the background in a Terminal window, and it might not be a good idea to close the window while one is running, at least not without finding out what’s going on.
有多种原因可能会导致应用程序在终端窗口的后台运行,并且在运行时关闭窗口可能不是一个好主意,至少在没有发现正在发生的情况的情况下也是如此。
Which is where the Inspector comes in handy. With the Terminal open, hit Command+I to bring up the Inspector. Alternatively, you can click Shell > Show Inspector in the menu bar. Either way a side window will open.
这是检查员派上用场的地方。 在终端打开的情况下,按Command + I以启动检查器。 或者,您可以在菜单栏中单击“外壳程序”>“显示检查器”。 无论哪种方式,都会打开一个侧窗。
This is the Inspector, and it allows you to change a number of settings. You can set a name for the currently open window, useful if you’re the kind of person who has several different Terminals open at a time, and you can change the size of the window and change the background color.
这是检查器,它使您可以更改许多设置。 您可以为当前打开的窗口设置一个名称,如果您是一次同时打开多个终端的人,则可以使用此名称,并且可以更改窗口的大小并更改背景颜色。
What interests us, however, is at the bottom of the window: a list of the currently open processes.
但是,我们感兴趣的是位于窗口底部:当前打开的进程的列表。
In our case we’ve got cmus, a music player, stopped in the background—I must have used Control+Z to stop the application instead of actually closing it. I could use the command fg
to switch back to the suspended program, but I’m fine just closing the application. You’ll need to recognize the program and determine whether it’s important to keep it running.
在我们的例子中,我们有一个音乐播放器cmus在后台停止—我必须使用Control + Z停止该应用程序,而不是实际关闭它。 我可以使用命令fg
切换回挂起的程序,但是可以关闭应用程序。 您需要识别该程序,并确定保持其运行是否重要。
If you’d like to close a given process, right-click its name in the list, then go to Signal Process Group and click Kill.
如果要关闭给定的进程,请在列表中右键单击其名称,然后转到Signal Process Group,然后单击Kill。
This will close the program instantly, allowing you to close your window without worry.
这将立即关闭程序,使您无需担心即可关闭窗口。
If you think this is useful, consider checking out our list of Bash keyboard shortcuts for macOS, along with some just for fun tricks hidden in the macOS Terminal. There’s a lot to explore here, so dive in and learn something new. Thanks to Alyssa Ross for teaching me the above trick!
如果您认为这很有用,请考虑查看我们针对macOS的Bash键盘快捷键列表,以及一些隐藏在macOS Terminal中的有趣技巧。 这里有很多值得探索的地方,因此请深入学习新的知识。 感谢Alyssa Ross教给我上述技巧!