Linux, kill command

I am using RHEL 6.4

In Unix based OS's, you perform something like

    ps -ef | grep appname

Open in new window


This command returns a PID, from which you perform something like

   kill -9  9999

Open in new window


This is simple enough, but sometimes I am in a hurry,

Is there a command or a script that can ferform something like

   killapp   appname

Open in new window


without the necessary PID lookup, turning it into a single command instead of two ?

Thanks
Los Angeles1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
omarfaridConnect With a Mentor Commented:
you could use pkill command for that

pkill appname

http://linux.die.net/man/1/pkill
0
 
Pepe2323Connect With a Mentor Commented:
Hi

Yes there is something like this.

if you use pkill app name i will kill the process related with that app name

 pgrep,  pkill  -  look  up or signal processes based on name and other
       attributes

Regards.
0
 
MazdajaiConnect With a Mentor Commented:
Keep it mind that pkill search for names / pattern - be careful when you use it on generic names like bin or usr.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Or just write a simple wrapper script that does the ps for you, filtering the pid(s), adding a simple check that asks you a question in case it finds more than one pid.
0
All Courses

From novice to tech pro — start learning today.