- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- killing process pid with a script ???
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
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
12-27-2000 09:39 AM
12-27-2000 09:39 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 09:51 AM
12-27-2000 09:51 AM
SolutionThere are a couple of ways you can do it, and I have done at least 2 of them! One way is to store the pid in a temp file on start-up of the process, then when you're ready to kill it, you just grap the contents of that temp file. Another way is using ps, grepping for what you want and don't want, and then using awk to strip out just the PPID (parent process id). If you need samples, let me know.
HTH,
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 09:56 AM
12-27-2000 09:56 AM
Re: killing process pid with a script ???
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 10:01 AM
12-27-2000 10:01 AM
Re: killing process pid with a script ???
This is actually a very simple process. Attached is a script that will look for "program_name" and kill it's process id. If this is running from something like cron, you might want to source the /etc/profile in the script to set up the correct environment.
Josef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 10:05 AM
12-27-2000 10:05 AM
Re: killing process pid with a script ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 10:30 AM
12-27-2000 10:30 AM
Re: killing process pid with a script ???
Try this script:
ee=`ps -e | grep process_name |cut -c2-6`
kill -9 $ee
If it is a rogue process try:
ee=`ps -e|grep process_name | grep "?" |cut -c2-6`
kill -9 $ee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 10:57 AM
12-27-2000 10:57 AM
Re: killing process pid with a script ???
Another problem is that the program you are looking for may have a short name which is part of another program's name as in: myprocess and myprocess2 and myprocess3. If you kill all processes called "myprocess", you'll also kill myprocess1 and myprocess2.
It's also important to handle the multiple occurances of the same program...do you want to kill avery occurance or just the first one you find or the one with the oldest start time...?
The example script that Maureen posted shows a great feature in ps, the -o option. But this will not work (see than man page) unless you set the ENV variable called UNIX95. Since UNIX95 set in the environment also affects *many* other processes *and* libraries, it's not advisable to globally set this variable. Instead, set it just for the ps command as in:
UNIX95= ps -e -o 'pid,ppid,comm'
It's a good idea to put the word: echo in front of the kill commands while you are testing the script. That way, you'll see what the script will do before it's too late. Be sure to trap any process owned by root and don't kill it!
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 11:22 AM
12-27-2000 11:22 AM
Re: killing process pid with a script ???
Good points! The scripts I submitted were actually for a Sun box, and I forgot that I had to set the UNIX95 variable first for HP. Also a great point on the 'echo kill', that's what I always do while testing!
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2000 11:46 AM
12-27-2000 11:46 AM
Re: killing process pid with a script ???
I want to thank everyone for your help..
I tried to give everyone a 10 but it didnt let me.
thanks allot guys.
case closed.