LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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: 61
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: 61
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: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:15 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration