how to kill a process, if we have the process name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rasmidas
    New Member
    • Jun 2007
    • 56

    how to kill a process, if we have the process name?

    Inside a shell script, how can we kill a process during run time, if we know only the process name.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    On linux there's a util called 'pidof'
    Code:
    /tmp # pidof apache
    /tmp # pidof httpd2-prefork
    19760 19740 19730 19672 19607 19604 7665 6781 6778 2276 2270
    To kill the prcess(es) of i.e. apache, you could do:
    Code:
    kill `pidof httpd2-prefork`

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      Or, if you're interested in killing everything related to the process, you can use killall. For instance, if Mozilla freezes:
      Code:
      killall mozilla

      Comment

      Working...