pskiller
Publicado por José Lopes 06/09/2006
[ Hits: 6.183 ]
Homepage: https://lopes.id
Este script recebe o nome de um processo e, opcionalmente, um sinal do sistema e mata todos os processos em execução que obedecerem ao nome passado. Além disso ele pode receber uma lista de processos para matar, também com sinal de término. Ex: ./pskiller nets #Mata tudo com NETS, como NETScape; ./pskiller -9 emacs #Mata tudo com EMACS com sinal -9; ./pskiller net ema #Mata tudo com NET e EMA; ./pskiller -9 konque firefox #Mata tudo com KONQUE e FIREFOX com sinal -9
#!/bin/bash # NAME ........: pskiller # AUTHOR ......: José Lopes de Oliveira Júnior # DESCRIPTION .: # Kills a process by a name. But it accepts non complete names, like # netsc for NETSCape, or mac for eMACs. It also accepts the signal to kill # the processes. A list of process can be eigther passed to the script, even # combined with a process signal for all processes, like in the examples: # $ pskiller ema fire soffice kick # $ pskiller -9 xmm # WARNING : Be sure to put on the processes' list, not ambigous names, like # kde, for example, because it'll kill all processes that have this pattern on # their names (all process that have in their names, the kde pattern, for # example). # OBSERVATION .: Give it 700 permition for a single user, or 755 for more users. SIG="-SIGTERM" # Default signal # Verifying the parameters if [ "$#" -lt 1 ]; then echo "Usage: pskiller [-SIGNAL] pattern" return fi # The signal was defined by the user? if [ "$#" -gt 1 ]; then # If the 1st parameter begins with '-', then it's a signal. case "$1" in # Redefine the signal and remove it from the parameters' vector -* ) SIG=$1 shift ;; esac fi # Processes PID & NAME and a control variable PID="" PNAME="" CONTROL="NO" # Evaluates all parameters for PNAME in "$@"; do for PID in `ps x --format pid,comm | \ sed -n "s/^ *\([0-9][0-9]*\) [^ ]*$PNAME.*/\1/p"`; do CONTROL="YES" # The informed process exists echo -e "Trying to kill process $PNAME ($PID) with signal $SIG... \c" kill $SIG $PID > /dev/null # Kill and don't show any messages echo "done." done # The informed process does not exists if [ $CONTROL = "NO" ]; then echo "Process $PNAME not found." fi # Restarting the control variable CONTROL="NO" done # EOF
Instalar emuladores no Fedora 22
Baixando e instalando BrOffice 3.1
Script - muda conteúdo de arquivos texto de iso-8859-1 para utf8 recursivamente
Nenhum coment�rio foi encontrado.
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
Jogos baixados na Central de Aplicativos mas que não abrem (1)
debian com wayland, configuracao de teclado. Mudou Tudo! [RESOLVIDO] (1)
Iinstalar o Scanner Kodak i940 no Linux Mint 19/20? (3)
Pastas da raiz foram para a área de trabalho [RESOLVIDO] (11)