- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Kill processes that follow
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:07 AM
02-04-2005 01:07 AM
I want to kill all the processes that are listed after the 'Marker Process', i.e. Process4, Process5, Process6.
For this I need to extract the process ID of the processes listed after the 'Marker Process'.
Can someone please suggest a way to extract those PIDs. I know that awk '{print $9}' will get me the PIDs, but I only want the ones listed after the 'Marker Process'.
The next line in my code would read:
kill -9 $killproc
where killproc has the process ids of the above mentioned processes.
Thanks
Solved! Go to Solution.
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:35 AM
02-04-2005 01:35 AM
Re: Kill processes that follow
can you use the following to extract the data:
cat
This should extract all the lines from MarkerProcess onwards.
You can then awk the process id and you should be done.
Hope this solves the problem.
Regards
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:40 AM
02-04-2005 01:40 AM
SolutionThis one line should work (/tmp/input is the output you enclosed in your posting):
cat /tmp/input | sed -n '/MarkerProcess/,//p' | grep -v "MarkerProcess" | awk {'print $9'} | xargs kill -9
I'm assuming here though that you will only have Processx lines after the MarkerProcess line? If not, you can enter another grep to ensure you only have Processx lines to kill:
cat /tmp/kfb.input | sed -n '/MarkerProcess/,//p' | grep -v "MarkerProcess" | grep "^Process" | awk {'print $9'}
All the best - Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:46 AM
02-04-2005 01:46 AM
Re: Kill processes that follow
cat /tmp/input | sed -n '/MarkerProcess/,//p' | grep -v "MarkerProcess" | grep "^Process" | awk {'print $9'} | xargs kill -9
Have fun - Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:56 AM
02-04-2005 01:56 AM
Re: Kill processes that follow
This is a very powerful tool. Read the code, be familiar with it.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 02:21 AM
02-04-2005 02:21 AM
Re: Kill processes that follow
I was not able to follow what the line you entered does. Would really appreciate if you could explain what '/^$/n;p' does.
When I tried using it in my code, and redirected the output to another file, I got an output with the MarkerProcess missing.
But its also listing Process1, Process2 and Process3. I only want Process4, Process5 and Process6 (that follow after MarkerProcess) to get listed. How do I get rid of those ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 02:44 AM
02-04-2005 02:44 AM
Re: Kill processes that follow
That line was beautiful. Its solved my problem in a jiffy.
Trouble is, now I really want to know how it works. :-)
cat /tmp/input | sed -n '/MarkerProcess/,//p' | grep -v "MarkerProcess" | awk {'print $9'} | xargs kill -9
Understood that the grep -v command helped us exclude 'MarkerProcess' from the search.
Why did you use the ',//p' ? What does it do ?
Google showed me that:
# To print only lines which match regular expression (emulates "grep")
sed -n '/regexp/p'
But sed -n '/MarkerProcess/p' did not work. It gave me a bad argument error. :-S Curious.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 02:47 AM
02-04-2005 02:47 AM
Re: Kill processes that follow
Thanks for the gkill. Really appreciate the idea.
Keith made the moves really swift. :-))