Created
June 3, 2012 06:09
-
-
Save zoek1/2862188 to your computer and use it in GitHub Desktop.
Matar la primera instancia de un proceso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function NoProceso { | |
echo "No existe Proceso "$1 | |
} | |
function KillProceso { | |
kill -9 $1; | |
status=$? | |
echo $status | |
if [ $status -eq 0 ]; then | |
echo "Proceso eliminado con pid "$1 | |
fi | |
} | |
if [ $1 != "" ]; then | |
echo "Intentar matar proceso "$1 | |
Programa=$1 | |
pid=$(ps -A | awk '/'$Programa/' { print $1 }'); | |
if [ -n "$pid" ]; then | |
KillProceso $pid; | |
else | |
NoProceso $Programa; | |
fi | |
else | |
echo "Falta nombre del proceso"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment