- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: Cut command usage in
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
тАО10-12-2008 09:07 PM
тАО10-12-2008 09:07 PM
$ ps -aef |grep mountd*
root 546 1 0.0 Oct 09 ?? 0:00.03 /usr/sbin/mountd -n -i -n
root 562 1 0.0 Oct 09 ?? 0:00.00 /usr/sbin/automount -m /net -hosts -nosuid
root 45657 13758 0.0 10:18:27 pts/0 0:00.01 grep mountd*
My main objective is to check for existing daemon (mountd) runs.If it runs i must kill particular pid's.
Say here i must do "kill -9 546" and kill -9 562". Please let me know how to use CUT or AWK command to kill above two pid's..
Thanks in Advance,
Shammer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2008 09:49 PM
тАО10-12-2008 09:49 PM
SolutionThis works if you have a real shell, ksh. Add "echo" to the beginning to make sure it's correct.
Note: If you were on HP-UX you would never use grep but the -C option:
kill -9 $(UNIX95=ENHANCED_PS ps -opid= -C mountd,automount)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2008 09:59 PM
тАО10-12-2008 09:59 PM
Re: Cut command usage in
grep mountd*
is doing? Hint:
mkdir new_dir
cd new_dir
and try your command again.
Second, you can eliminate your "grep" command
from the "ps" listing by using a popular
trick:
urtx# ps -aef | grep [m]ount
root 478 1 0.0 00:31:37 ?? 0:00.00 /usr/sbin/mountd -i
root 493 1 0.0 00:31:38 ?? 0:00.00 /usr/sbin/automount -m /net -hosts -nosuid
Third, I can remember how to use "sed", but
I'd need to read up on "awk" or "cut".
urtx# ps -aef | grep [m]ount | sed -e 's/ *[^ ]* *\([^ ]*\) .*/\1/'
478
493
If it's not obvious how to do the "kill"
commands from a list of pid's, then you might
try something like this:
urtx# ps -aef | grep [m]ount | sed -e 's/ *[^ ]* *\([^ ]*\) .*/\1/' | \
while read pid ; do echo kill ${pid} ; done
kill 478
kill 493
When you're happy, remove "echo".
Now that we've solved _that_ problem, what is
the _real_ problem which you are trying to
solve? And why would killing these processes
be the best way to solve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2008 10:05 PM
тАО10-12-2008 10:05 PM
Re: Cut command usage in
anything which your "grep" will falsely
interpret as one of the processes you're
trying to kill. Or else do a much more
precise search for the processes which you
_really_ wish to kill (user, parent pid, more
complete path, and so on), which would be
harder to do on one line.
> Note: If you were on HP-UX [...]
Yeah. I'd convert all _my_ software to get a
"ps" with that feature.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2008 02:24 AM
тАО10-13-2008 02:24 AM
Re: Cut command usage in
Thanks a lot for time on this..
Closing this thread..
Thanks,
Shammer