无法在不打开作业的情况下终止作业

时间:2020-12-31 02:20:09

I run the following code unsuccessfully

我运行以下代码失败

sudo killall %4

where %4 is my Vim session.

其中%4是我的Vim会话。

How can you terminate a job without foregrounding it?

如何在没有前景化的情况下终止工作?

2 个解决方案

#1


I believe you want "kill" instead of "killall". I tested under tcsh like this:

我相信你想要“杀”而不是“killall”。我在tcsh下测试过这样的:

home% cat
^Z
Suspended
home% kill %1
home% 
[1]    Terminated                    cat

Furthermore, I doubt this would work with sudo because sudo would invoke a new shell, wouldn't it? And in that shell, %4 would not be defined.

此外,我怀疑这对sudo有用,因为sudo会调用一个新的shell,不是吗?在那个shell中,%4将不会被定义。

home% cat
^Z
Suspended
home% sudo kill %1
Password:
kill: illegal process id: %1

If you really need to sudo, you can try this:

如果你真的需要sudo,你可以试试这个:

home% jobs -l
[1] + 26318 Suspended cat
home% sudo kill 26318

#2


Try kill %4 instead. The unix shell uses %x as variables for currently running processes. To see the processes you can use with the %x syntax, use jobs. Killall is a wrapper around "kill" that is basically the equivalent of `ps -aux | grep | cut -f2 -d " " | xargs kill' or the like if you're a shell junky.

尝试杀死%4。 unix shell使用%x作为当前正在运行的进程的变量。要查看可以与%x语法一起使用的进程,请使用作业。 Killall是一个围绕“kill”的包装器,它基本上相当于`ps -aux | grep | cut -f2 -d“”|如果你是一个外壳垃圾,xargs会杀死'等等。

No, sorry, that shell command won't quite work, but it does illustrate how killall works =p. It simply kills every process it can that matches the string you provide.

不,对不起,那个shell命令不会起作用,但它确实说明了killall如何工作= p。它只会杀死与你提供的字符串相匹配的每个进程。

Also, try `man kill' to learn more about kill. Particularly, kill -9 you may find useful. It's sorta the equivalent of 'force quit'.

另外,尝试“杀人”以了解更多有关杀戮的信息。特别是,kill -9你可能会觉得有用。它有点像'强行退出'。

#1


I believe you want "kill" instead of "killall". I tested under tcsh like this:

我相信你想要“杀”而不是“killall”。我在tcsh下测试过这样的:

home% cat
^Z
Suspended
home% kill %1
home% 
[1]    Terminated                    cat

Furthermore, I doubt this would work with sudo because sudo would invoke a new shell, wouldn't it? And in that shell, %4 would not be defined.

此外,我怀疑这对sudo有用,因为sudo会调用一个新的shell,不是吗?在那个shell中,%4将不会被定义。

home% cat
^Z
Suspended
home% sudo kill %1
Password:
kill: illegal process id: %1

If you really need to sudo, you can try this:

如果你真的需要sudo,你可以试试这个:

home% jobs -l
[1] + 26318 Suspended cat
home% sudo kill 26318

#2


Try kill %4 instead. The unix shell uses %x as variables for currently running processes. To see the processes you can use with the %x syntax, use jobs. Killall is a wrapper around "kill" that is basically the equivalent of `ps -aux | grep | cut -f2 -d " " | xargs kill' or the like if you're a shell junky.

尝试杀死%4。 unix shell使用%x作为当前正在运行的进程的变量。要查看可以与%x语法一起使用的进程,请使用作业。 Killall是一个围绕“kill”的包装器,它基本上相当于`ps -aux | grep | cut -f2 -d“”|如果你是一个外壳垃圾,xargs会杀死'等等。

No, sorry, that shell command won't quite work, but it does illustrate how killall works =p. It simply kills every process it can that matches the string you provide.

不,对不起,那个shell命令不会起作用,但它确实说明了killall如何工作= p。它只会杀死与你提供的字符串相匹配的每个进程。

Also, try `man kill' to learn more about kill. Particularly, kill -9 you may find useful. It's sorta the equivalent of 'force quit'.

另外,尝试“杀人”以了解更多有关杀戮的信息。特别是,kill -9你可能会觉得有用。它有点像'强行退出'。