HeatWare.net header image
HeatWare.net
TwitterRSSEmail
  • Home
  • Windows
    • Windows 8
    • Windows 7
    • Windows Vista
    • Windows XP
  • Linux/Unix
  • Mac
  • Mobile
    • Android
    • iOS
    • Phones (Help / Resources)
  • Software / Programming
    • Free Software
    • Programming – General
    • PHP
    • Ruby/Rails
    • Quality Assurance (QA)
    • Software – General
    • Software Help
    • Databases
  • Cool Websites
  • Other
    • Deals & Bargains
    • News
    • Video Games
    • Hardware
    • Electronics
  • About

3 comments / November 16, 2009 / sood / Linux/Unix

Linux: How to Kill all instances of a script/program by using a string search

This article will show you how to kill (or end) multiple processes or instances of a running script with a single command.

If you are like me, you have run into this situation many many times. You run the ps command to list all the currently running processes and you see that there are multiple instances running of a certain program. You want to end all these instances but do not want to run the kill command for each one of those specifying the pid manually. Killing all instances of this program is very simple and I’ll show you how to do it using a 1 line command!

How to Kill multiple instances of a process

  1. Log into the shell of your Linux/Unix box
  2. If you do not know the name of the script you will like to kill, run: ps -ef This will show you a list of all the currently running processes. In the right-most column, you will find the path and filename of the script you want to end.
  3. To kill all instances of this script, run the command: ps -ef | grep [search string] | awk '{print $2}' | xargs kill -9 Be sure you substitute [search string] to your own value.
  4. Now run ps –ef again and all running instances of that script will be gone!

 

Alternative Method

If your Linux distribution has pkill installed, simply run the command:

pkill -9 -f [search string]

Digg This

Related Posts

  • Run a script on Linux startup in 2 simple steps
  • New Nursing Job Search Site - Nursewala.com
  • Insert/Add String to Beginning of a File
  • Shell command to bulk change file extensions in a directory (Linux)
  • Force Visual Studio to always run as an Administrator in Windows 8

Linux/Unix Shell

3 comments… add one
  1. moe Caruso December 15, 2010, 8:22 am

    Ever heard about the “killall” command??

  2. anonymous June 7, 2012, 1:34 am

    i’ve heard about that, i’ve also heard that sometimes it is not installed…

  3. sintetix February 4, 2015, 9:17 am

    For some reason killall doesn`t work in script, only in console at my android phone. pkill performs fine everywhere

Cancel reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Why You Should Consider Diving Apps
  • How to Buy a Smartphone that Fits Your Budget
  • How to Overcome Frustrating PDF Stress
  • Convert PDF to Word: Easy, Reliable and Quality Conversion
  • PDF to Excel App ­ – A New Way of Handling Tricky Documents

Recent Comments

  • Valarie Walter on Basic Troubleshooting Steps for your Cell Phone
  • John Mists on A Brief History of Android OS
  • syarif on PostgreSQL: How to reload config settings without restarting database
  • Raghu on How to SSH to a server using Ruby – Part I
  • francisco clemente on Basic Troubleshooting Steps for your Cell Phone

Tags

ACSLS Android Bargain Cell Phones Cool Software Cool Websites Databases Deals Ebooks Facebook Free Software G2x Galaxy S5 iOS iPhone Kindle LG Linux Linux/Unix Mac Mobile mysql Office OpenStack OS X PHP Postgres PostgreSQL ruby Samsung Galaxy S6 Shell Smartphones Sun T-Mobile Tips Tips & Tricks Ubuntu Unix Virtualization VMWare Windows Windows 7 Windows 8 Windows Vista Windows XP

Latest Tweet

Follow @HeatwaredotNet

SP
@HeatwaredotNet

  • Why You Should Consider Diving Apps https://t.co/Is41cdUv2I #diving-apps
    about 6 years ago

All Categories

Other Links

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2015 — HeatWare