GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come uccidere un processo con una frase nel suo nome??

Questa domanda ha già risposte qui :Come uccido i processi in Ubuntu?

(12 risposte)
Chiuso 5 anni fa.

Ho bisogno di terminare un processo che contiene myName nella sua descrizione. Attualmente sto facendo:

ps -ax |grep myName
I see PID
kill -9 PID

Come posso fare lo stesso con un comando senza inserire il PID?

Risposta accettata:

Se myName è il nome del processo/eseguibile che vuoi eliminare, puoi usare:

pkill myName

pkill per impostazione predefinita invia il SIGTERM segnale (segnale 15). Se vuoi il SIGKILL o segnale 9, usa:

pkilll -9 myName

Se myName non è il nome del processo o, ad esempio, è un argomento per un altro comando (lungo), pkill (o pgrep ) potrebbe non funzionare come previsto. Quindi devi usare -f opzione. Da man kill :

-f, --full
              The pattern is normally only matched against the  process  name.
              When -f is set, the full command line is used.
NOTES
The process name used for matching is limited to the 15 characters present
   in the output of /proc/pid/stat.  Use the -f option to match  against  the
   complete command line, /proc/pid/cmdline.

Quindi:

pkill -f myName

o

kill -9 $(pgrep -f myName)

Ubuntu
  1. Come uccidere un processo zombie su Linux

  2. Come scrivere il percorso di una cartella con spazio nel suo nome??

  3. Come faccio a trovare e terminare un processo in Ubuntu

  4. Come identificare la porta di un processo?

  5. Come terminare un processo <defunct> con il genitore 1

Come individuare e terminare un processo con il terminale Linux

Come avviare e terminare un processo in Ubuntu 20.04 LTS

Come uccidere i processi zombie in Ubuntu 20.04 LTS

Come KILL un processo su Linux

Come trovare il nome del processo dal suo PID

Se conosco il numero PID di un processo, come posso ottenere il suo nome?