- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Killing a process witha script PART 2
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
Discussions
Discussions
Forums
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
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-22-2006 12:14 PM
тАО02-22-2006 12:14 PM
I'm using the suggestion from my previous post...
PID=(ps -ef|grep <[P]rocess> | awk '{print $2}')
to get the PID of a process that is running so I can execute a kill on it. This seemed to work the first time I ran it. Now I am getting a set of 3 numbers in my return, such as "12345 67890 09877". How can I correct this? Thanks.
Solved! Go to Solution.
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 12:46 PM
тАО02-22-2006 12:46 PM
SolutionUNIX95=1 ps -C
Now the above eliminates both grep and awk because ps can provide all you need. As far as having multiple PID's returned, with the above examp[le, it means that there are multiple copies of the program running. To see them in detail, just change -o pid to -f.
Bill Hassell, sysadmin
- Tags:
- UNIX95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 03:41 PM
тАО02-22-2006 03:41 PM
Re: Killing a process witha script PART 2
Simply,
PID=$(ps -ef | gre[ <[P]rocess> | grep -v grep | awk '{ print $2; })
However, It is not always useful. Try to use UNIX95 format. That is good.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 03:47 PM
тАО02-22-2006 03:47 PM
Re: Killing a process witha script PART 2
It is not good practice to club "ps" and "grep" together, UNIX 95 variable which bill said is the best method.
# UNIX95= ps -C"exact_process_name" -o pid
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2006 12:57 PM
тАО02-23-2006 12:57 PM
Re: Killing a process witha script PART 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2006 01:16 PM
тАО02-23-2006 01:16 PM
Re: Killing a process witha script PART 2
# UNIX95= ps -C"exact_process_name" -o pid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2006 01:19 PM
тАО02-23-2006 01:19 PM