Created
December 28, 2016 06:56
-
-
Save Venkat2811/ecfc9b1e7bd22506494a3070a2c50b9d to your computer and use it in GitHub Desktop.
Shell script to grep and kill all process by name. Usage `sudo ./kill_all_processes_by_name.sh process_name`
This file contains hidden or 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 | |
| i="1" | |
| echo "Running Script to kill all $1 processes" | |
| while [[ $i -lt 100 ]]; do | |
| PID=`ps -ef | grep $1 | grep -v 'grep' | awk '{print $2}'` | |
| if [[ "" != "$PID" ]]; then | |
| echo "killing $PID" | |
| kill -9 $PID | |
| fi | |
| i=$(( $i + 1 )) | |
| done | |
| echo "Done.." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment