我可以中止当前运行的bash命令吗?

时间:2022-01-19 20:47:36

Is it possible to manually abort the currently running bash command? So, for example, I'm using 'find' but it's taking ages... how do I manually stop it?

是否可以手动中止当前运行的bash命令?举个例子,我用的是“find”,但它要花很长时间……我如何手动停止它?

3 个解决方案

#1


28  

Some things won't respond to Ctrl+C; in that case, you can also do Ctrl+Z which stops the process and then kill %1 - or even fg to go back to it. Read the section in man bash entitled "JOB CONTROL" for more information. It's very helpful. (If you're not familiar with man or the man pager, you can search using /. man bash then inside it /JOB CONTROLEnter will start searching, n will find the next match which is the right section.)

有些东西对Ctrl+C没有反应;在这种情况下,您还可以按Ctrl+Z停止进程,然后杀死%1 -甚至fg返回进程。要了解更多信息,请阅读manbash中的“作业控制”一节。它是非常有用的。如果你对人或寻呼机不熟悉,你可以用/搜索。man bash然后在其中/JOB CONTROLEnter将开始搜索,n将找到下一个匹配,这是正确的部分。

#2


10  

Ok, so this is the order:

这是顺序:

1st try: Ctrl+c

试1:按Ctrl + c

2nd try: Ctrl+z

试2:按Ctrl + z

3rd: login to another console, find the process of the command within your first console that is not responding to both previously mentioned abort/sleep keystrokes with: ps aux

第三:登录到另一个控制台,在您的第一个控制台中找到没有响应前面提到的中止/睡眠按键的命令进程:ps aux

Then kill the process with: kill -9 <PROCESSID>

然后用:kill -9 杀死进程

Of course there may be smarter parameters to the ps command or the possibility to grep , but this would complicate the explanation.

当然,ps命令可能有更聪明的参数,也可能有grep,但这将使解释更加复杂。

#3


6  

Press CtrlC to send SIGINT to the command to attempt to interrupt it.

按ctrl - lc将SIGINT发送到命令,尝试中断它。

#1


28  

Some things won't respond to Ctrl+C; in that case, you can also do Ctrl+Z which stops the process and then kill %1 - or even fg to go back to it. Read the section in man bash entitled "JOB CONTROL" for more information. It's very helpful. (If you're not familiar with man or the man pager, you can search using /. man bash then inside it /JOB CONTROLEnter will start searching, n will find the next match which is the right section.)

有些东西对Ctrl+C没有反应;在这种情况下,您还可以按Ctrl+Z停止进程,然后杀死%1 -甚至fg返回进程。要了解更多信息,请阅读manbash中的“作业控制”一节。它是非常有用的。如果你对人或寻呼机不熟悉,你可以用/搜索。man bash然后在其中/JOB CONTROLEnter将开始搜索,n将找到下一个匹配,这是正确的部分。

#2


10  

Ok, so this is the order:

这是顺序:

1st try: Ctrl+c

试1:按Ctrl + c

2nd try: Ctrl+z

试2:按Ctrl + z

3rd: login to another console, find the process of the command within your first console that is not responding to both previously mentioned abort/sleep keystrokes with: ps aux

第三:登录到另一个控制台,在您的第一个控制台中找到没有响应前面提到的中止/睡眠按键的命令进程:ps aux

Then kill the process with: kill -9 <PROCESSID>

然后用:kill -9 杀死进程

Of course there may be smarter parameters to the ps command or the possibility to grep , but this would complicate the explanation.

当然,ps命令可能有更聪明的参数,也可能有grep,但这将使解释更加复杂。

#3


6  

Press CtrlC to send SIGINT to the command to attempt to interrupt it.

按ctrl - lc将SIGINT发送到命令,尝试中断它。