навык не работает, чтобы убить сеанс в Redhat 7 box

Вы не можете сделать это за один раз с помощью grep . Вам нужно использовать два экземпляра grep :

grep 'string1' file; grep -A 5 'string2' file

Если вы хотите запустить второй после успеха первого:

grep 'string1' file && grep -A 5 'string2' file
1
09.03.2019, 10:53
2 ответа

Una posible respuesta si los usuarios están conectados a través de ssh:

pkill -f <myusername>@pts/1

Para otros casos:

who -u 

end then kill pid (s ), o por ejemplo para matar todas las sesiones de usuario excepto la de root:

$ who -u | awk '!/^root /{print $6}' |xargs sudo kill
1
27.01.2020, 23:32

Observando que la página del manual de habilidad dice:

These tools are probably obsolete and unportable. The command syntax is poorly defined. Consider using the killall, pkill, and pgrep commands instead

Creo que la sintaxis que estás buscando es:

skill -t pts/0 -t pts/1 -t pts/3

... ya que parece que la sintaxis expressionrequiere un tty por bandera -t.

En cuanto a por qué skill no está eliminando los procesos, mi sospecha es que el formato de /proc/PID/stat cambió desde que se compiló skill, lo que provocó que se saltara el proceso en el check _proc function(en una copia arbitraria de github de skill.c encontré ). Parece analizar /proc/PID/stat manualmente y nunca envía una señal de interrupción al proceso (es):

open("/proc/21102/stat", O_RDONLY)      = 4
read(4, "21102 (bash) S 21101 21102 21102"..., 128) = 128

...

open("/proc/22839/stat", O_RDONLY)      = 4
read(4, "22839 (view) S 21102 22839 21102"..., 128) = 128

Cuando compilo una copia nueva de la habilidad, funciona según lo previsto:

open("/proc/22926/stat", O_RDONLY)      = 4
read(4, "22926 (bash) S 22925 22926 22926"..., 128) = 128
readlink("/proc/22926/tty", 0x7f3e47e073e0, 127) = -1 ENOENT (No such file or directory)
readlink("/proc/22926/fd/2", "/dev/pts/2", 127) = 10
kill(22926, SIGKILL)                    = 0

Seguiría la sugerencia de la página de manual y tonioc y cambiaría a pkill; por ejemplo, para matar procesos en pts/1 y/o pts/2:

pkill -HUP -t pts/1,pts/2
1
27.01.2020, 23:32

Теги

Похожие вопросы