Solved

Linux, kill command

Posted on 2013-05-24
4
426 Views
Last Modified: 2013-05-24
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
Comment
Question by:Los Angeles1
4 Comments
 
LVL 8

Assisted Solution

by:Pepe2323
Pepe2323 earned 167 total points
Comment Utility
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
 
LVL 40

Accepted Solution

by:
omarfarid earned 167 total points
Comment Utility
you could use pkill command for that

pkill appname

http://linux.die.net/man/1/pkill
0
 
LVL 21

Assisted Solution

by:Mazdajai
Mazdajai earned 166 total points
Comment Utility
Keep it mind that pkill search for names / pattern - be careful when you use it on generic names like bin or usr.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now