473,378 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.
May 4 '12 #1
2 3549
Luuk
1,047 Expert 1GB
On linux there's a util called 'pidof'
Expand|Select|Wrap|Line Numbers
  1. /tmp # pidof apache
  2. /tmp # pidof httpd2-prefork
  3. 19760 19740 19730 19672 19607 19604 7665 6781 6778 2276 2270
  4.  
To kill the prcess(es) of i.e. apache, you could do:
Expand|Select|Wrap|Line Numbers
  1. kill `pidof httpd2-prefork`
May 4 '12 #2
sicarie
4,677 Expert Mod 4TB
Or, if you're interested in killing everything related to the process, you can use killall. For instance, if Mozilla freezes:
Expand|Select|Wrap|Line Numbers
  1. killall mozilla
  2.  
May 7 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Carlo Filippini | last post by:
Hi on a XP machine I start a ftp process with: $pid = open (CMD, "ftp -in -w:1024 -s:$file_cmd $server 2>&1 |") or die "Can't execute: $!"; In some occasions I want to kill the process, but I...
5
by: Thomas Chan | last post by:
I have an application that need to launch acrobat reader. But before I open acrobat reader, I want to check there is any existing acrobat reader opening and kill them first. What can I do? Can...
3
by: Wilfried Mestdagh | last post by:
Hi, I use C# 2005 beta with NET 2005 beta. How to kill a process ? Is this possible in this version ? I foundsom things in help but it is not clear to me, if someone can give me brief example it...
2
by: charmis | last post by:
Hi everyone, I am trying to include one feature using excel object in my application. I am giving the code to create and kill the process , that i got from Microsoft site.......but nothing is...
1
by: Lee Gillie | last post by:
I need to be able to kill a process programmatically under ASP.NET. IIS runs under the local system account. The user accessing the web is using anonymous access. We would prefer NOT to grant...
7
by: Joe | last post by:
If I'm using process.kill, I can only kill processes, which are created in the same login session. (I'm using win2000, I'm in the local admin group) Processes created by me in earlier logins or...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
3
by: Optix | last post by:
Hi,How do i terminate/kill a process based on its windows caption - C++ ? Would anyone mind posting an example source code of it? E.g I do not want calc.exe to ever run in my pc so i want to...
0
by: stef mientki | last post by:
hello, is there a library to kill a windows process by name ? thanks, Stef Mientki
4
by: yxq | last post by:
Hello, I want to kill the Explorer process, after Explorer process has been killed, it will restart automatically immediately. How to disable it restart automatically? for example, in Windows Task...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.