LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-25-2003, 09:29 PM   #1
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Rep: Reputation: 78
finding a PID and killing it


I wrote a script that starts the connection and my iptables script. I just type <script name> on the command line and the iptables script starts that the dial-up connections.
Here is my problem, I want to write a script that will kill the connection. Right now I do a ps -x, find the PID and do a kill PID number, on the command line.
How do I do this? I can do a ps -x | grep ppp0 > /tmp/modpid and print the pid number and name and such to a file. I just done know the commands to extract the PID number from the file and issue a kill to it. Any help is greatly appericiated. Thanks
 
Old 01-25-2003, 09:36 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Does your system support pkill? Or you could do something similar to the following for the long way around:
ps -ef | grep procname | awk '{print $2}' | xargs kill
 
Old 01-25-2003, 09:48 PM   #3
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
Look in the (/etc/) init.d or rc.d directory for the stop scripts your machine runs to shut itself down; You can hopefully read through some of these and use the same methods your distribution does as an example of how you should do it.
 
Old 01-25-2003, 10:14 PM   #4
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Original Poster
Rep: Reputation: 78
Thanks stickman, the ps -ef | grep/ ..... thing worked.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
logging off by script or finding PID of session bob_man_uk Red Hat 6 10-27-2005 03:37 AM
Killing a pid in C++ pilot1 Programming 4 09-20-2003 10:07 AM
killing tail --pid=??? DavidPhillips Linux - Software 1 08-13-2003 10:48 PM
finding pid with program name durden2.0 Linux - Newbie 1 08-04-2003 08:38 PM
Finding the first pid corrierich Linux - General 2 03-06-2003 02:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:57 AM.

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