Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Answer: How do i obtain the PID of a program already running.

by QandAEditors
on Jun 29, 2000 at 19:21 UTC ( #20395=categorized answer: print w/replies, xml ) Need Help??

Q&A > programs and processes > How do i obtain the PID of a program already running.

ps -C program_name

From the Chatterbox earlier today, you were wanting to kill all the apache PID's with Perl...

shell> ps -C httpd | perl -pe '($_)=/(\d+)/;`kill -9 $_`'
That should work as root

Enjoy!

--
Casey

Replies are listed 'Best First'.
RE: Answer: How do i obtain the PID of a program already running. UPDATE
by cwest (Friar) on Jun 29, 2000 at 19:25 UTC
    I can't update my own posts... grrr!

    Change perl -pe to perl -ne actually...

    ps -C httpd|perl -ne'($_)=/(\d+)/;`kill -9 $_` if $_'
    
    That seems better to me.
    --
    Casey
    
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-11-17 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (200 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!