How to kill an application or process in Linux using BASH

The pkill command kills a named application but it does not work all the time. It can even when used with sudo. The good old kill command is the ultimate solution. Hence, I have use this alias in my .bashrc file in the home directory.

alias kll='bash ~/Scripts/kll.txt'

In the script file, I have this code:

for sID in `pgrep $1`
do
  ps $sID
  kill -STOP $sID
done

for sID in `pgrep $1`
do
  ps $sID
  kill -KILL $sID
done

To kill an app, I type kll PROCESS-NAME. If it does not work, I would sudo it.

Advertisements
This entry was posted in software and tagged , . Bookmark the permalink.

Make a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s