LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-10-2007, 09:00 AM   #1
johngreenwood
Member
 
Registered: Nov 2006
Location: Lancashire, United Kingdom
Distribution: Slackware 13
Posts: 243

Rep: Reputation: 31
Looking for a way to find a PID and kill the process it belongs to


Hi all, I have an animation which plays during boot. I added a kill command with the PID to the startup scripts, but as the PID is subject to change it's not always reliable. I am looking for a way to find the PID automatically and kill the process, here is what I have so far:
Code:
ps | grep "fbmngplay" | cut -b 1-5 > fbm
Now I need to find a way to get the information from the file "fbm" to the kill command, but how? Also, if anyone knows a better way to achieve this, that would also be appreciated, thanks.

John
 
Old 01-10-2007, 09:03 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
This might work for you
kill $(pidof fbmngplay)
 
Old 01-10-2007, 09:08 AM   #3
johngreenwood
Member
 
Registered: Nov 2006
Location: Lancashire, United Kingdom
Distribution: Slackware 13
Posts: 243

Original Poster
Rep: Reputation: 31
Thanks for that homey, It worked like a charm. And there I was messing with all that crap. I need to learn more.

Thank you

John
 
Old 01-10-2007, 09:20 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
You're weclocme!
 
Old 01-10-2007, 11:56 AM   #5
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
you could stop it from running instead of killing it
 
Old 01-10-2007, 12:27 PM   #6
johngreenwood
Member
 
Registered: Nov 2006
Location: Lancashire, United Kingdom
Distribution: Slackware 13
Posts: 243

Original Poster
Rep: Reputation: 31
How would I stop it from running instead? What would that mean? Would the process still be there but not doing anything?
 
Old 01-14-2007, 05:45 AM   #7
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,276

Rep: Reputation: 61
If its a running process it's most likely started from a script or a binary, just find out how it's started and make script/binary non-executable.

chmod -x /some/script/somewhere
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the PID of a process using C programming? socialjazz Programming 3 10-06-2006 12:53 AM
kill pid.... won't work with 'pid' variable given.. sachitha Programming 6 03-06-2006 07:48 PM
using bash to find the pid of a process called "name" poiuytrewq Linux - Newbie 3 10-25-2004 09:01 PM
Where to find to whom an ip belongs to ? juanb Linux - Security 4 10-24-2004 02:56 PM
How to find the pid to stop a process.... vous Linux - Networking 6 08-14-2003 04:18 AM


All times are GMT -5. The time now is 02:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration