Solved

Linux, kill command

Posted on 2013-05-24
4
436 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
ID: 39195121
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
ID: 39195125
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
ID: 39195170
Keep it mind that pkill search for names / pattern - be careful when you use it on generic names like bin or usr.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 39195302
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
awk sed 8 63
ignore other .htaccess 2 58
HOw To Install Docker on VMware Workstation 19 151
how to include conditional log rotate in liunx. 17 28
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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 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