[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 456
  • Last Modified:

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
0
Los Angeles1
Asked:
Los Angeles1
3 Solutions
 
Pepe2323Commented:
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
 
omarfaridCommented:
you could use pkill command for that

pkill appname

http://linux.die.net/man/1/pkill
0
 
MazdajaiCommented:
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now