LinuxQuestions.org
Help answer threads with 0 replies.
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 09-11-2005, 09:21 AM   #16
pass
LQ Newbie
 
Registered: Sep 2005
Distribution: Debian GNU/Linux
Posts: 10

Original Poster
Rep: Reputation: 0

Thanks alot for the script JCipriani Since the router system is read only so i can't upload any script to it, do you know if it's possible to run that script by typing everything on a single command line and how to do it ?
 
Old 09-11-2005, 10:02 AM   #17
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
Type, all on one line at the command line:
Code:
for a in `ps ax | grep pppd | grep -v grep` ; do echo "Killing PID $a..." ; kill $a ; break ; done
You'd have to put some extra logic in to make it print "No process killed" at the end, if you want. In general, most of the shell script commands can be typed on the command line as well. You can use ;'s to separate statements or you can just type them one line at a time, in which case you'll be prompted to finish constructs like for loops and if statements.

If you aren't using sh or some derivative (you can tell if the above gives you syntax errors, assuming I didn't make a mistake), make sure you switch to sh first.

Last edited by JCipriani; 09-11-2005 at 10:04 AM.
 
Old 09-11-2005, 11:36 AM   #18
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
JCipriani: nice hack. It's quite elegant, actually.

Quote:
Originally posted by JCipriani

Oh... are sed and perl connected...?

Jason
I think the implication was that if the developers of the firmware cut sed to save space, then perl certainly wouldn't be in there.
 
Old 09-11-2005, 03:18 PM   #19
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
Quote:
It's quite elegant, actually.
If you say so, hehe.

Quote:
I think the implication was that if the developers of the firmware cut sed to save space, then perl certainly wouldn't be in there.
Oh right, that makes more sense. Thanks.
 
Old 09-11-2005, 07:11 PM   #20
pass
LQ Newbie
 
Registered: Sep 2005
Distribution: Debian GNU/Linux
Posts: 10

Original Poster
Rep: Reputation: 0
Awesome !
Thanks alot JCipriani worked perfectly
Cheers
 
Old 09-11-2005, 07:21 PM   #21
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Ah, the power of the shell.
 
Old 09-16-2005, 05:29 PM   #22
Riddick
Member
 
Registered: May 2004
Location: Rome, Italy
Distribution: slackware-current
Posts: 454

Rep: Reputation: 30
Excellent line there in the second post.
I Love it!

Riddick
 
Old 02-23-2006, 04:35 PM   #23
alexgd007
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Rep: Reputation: 0
Unhappy I need Help

I need to kill some porces that uses more of 90% of CPU I donīt konw who invoke this proces, so, for the moment I need to kill

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
7353 apache 25 0 3644 3640 1876 R 94.2 0.3 1:05 0 inetd
25852 apache 15 0 39228 38M 30324 S 1.9 3.8 0:08 0 /usr/sbin/httpd

as you seen I have 2 process the user is APACHE but in COMMAND you see the first is invoke for INETD and the second by /USR/SBIN/HTTPD

The first uses 94% of CPU, I killing manually usin Kill -9 7353(in this case or curent PID) and works fine but I need an script to do automatically becuse I dont be allways looking or monitoring

how I can do an script that detect apache using command initd and kill automatic each time that run

thank you for your help

Quote:
Originally Posted by btmiller
The following should work if you have grep and awk. If you don't have awk, you can use the cut command to do the same thing easily:

Code:
kill `ps aux | grep pppd | grep -v grep | awk '{print $2}'`
 
Old 02-23-2006, 04:39 PM   #24
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
It's very odd to see inetd being run as the user apache. Inetd is an important process to your system: killing it arbitrarily may well disconnect a number of services.
 
Old 02-23-2006, 04:45 PM   #25
alexgd007
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Rep: Reputation: 0
By the moment I need to kill apache invoke by inetd while I find who invoke the porcess
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 02:32 PM
Why does imwheel randomly take up 99% of resources until I kill/restart it :(!? SBing Linux - Software 0 07-13-2004 01:28 AM
Must kill pppd and restart for it to work,Mandrake 10.0 SharpyWarpy Mandriva 0 06-10-2004 02:49 AM
Does kill -HUP <id> restart the <id> process? feetyouwell Linux - Software 1 02-15-2004 10:48 PM
Cannot kill process - please help! thomas.nichols Linux - General 16 09-05-2001 06:43 AM

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

All times are GMT -5. The time now is 01:59 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