- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to determine a particular process on a particu...
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
08-28-2000 04:44 AM
08-28-2000 04:44 AM
How to determine a particular process on a particular box
I want a script to kill and restart a process (dtwm, in particular). My script has the following:
kill -9 `ps -deaf | grep -v grep | grep dtwm | grep $user_x | awk '{print $2}'`
dtwm &
where $user_x was the one running the script.
However, when someone tested the script, it failed because that person just happen
to be logged in the same system but at a different terminal.
How can I revise my script to kill the process that is on the box where they are at?
I don't want the process at some other box killed. When I do a "ps -deaf" for the
process the tty is listed as "?". It's the same for the process on the other box.
Any ideas?
thank you,
Boyd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:05 AM
08-28-2000 05:05 AM
Re: How to determine a particular process on a particular box
try the who -u command, it matches up a login with the IP address theyre coming from, this should be enough to make your script unique. I thought to restart somebodys window manager (dtwm) you needed to export your DISPLAY variable to their IP anyway ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:10 AM
08-28-2000 05:10 AM
Re: How to determine a particular process on a particular box
Try using this:
ee=`ps -ef|grep dtwm|grep "?"|cut -c2-8`
kill -9 $ee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:13 AM
08-28-2000 05:13 AM
Re: How to determine a particular process on a particular box
If the process only runs while a particular user is logged in, run in background so the process keeps running after the user logs out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:17 AM
08-28-2000 05:17 AM
Re: How to determine a particular process on a particular box
Firstly, I don't advise using kill -9 routinely. It pulls the rug from under the feet of the process. So, any locks/semaphores/shared memory etc don't get released.
So, I'd recommend at least changing the kill -9 to kill -1 or kill -15.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:50 AM
08-28-2000 05:50 AM
Re: How to determine a particular process on a particular box
dtwm would relate to which box give an IP address like this.
By the way, the script is run by the owner of the dtwm. The script would
not be killing somebody else's process, i.e. root will not run this script. I found no need for using $DISPLAY.
Tried the following:
`ps -ef|grep dtwm|grep "?"|cut -c2-8`
but that provides the owner of the process. And since our situation involves a user
with two dtwm processes and we want only one particular one killed, I don't see
how this method will help distinguish the one we want killed.
Here's some output after executing `ps -deaf | grep -v grep | grep dtwm | grep tester`:
tester 20367 20248 0 09:12:55 ? 0:01 dtwm
tester 19219 19143 0 08:33:08 ? 0:07 dtwm
For the idea to "grep for a process PID and not a user PID", I am not sure how grepping for the process PID will help me know which one of these is the right
one to terminate, unless you had in mind a process other than dtwm.
Yes, using `kill -15` is a better choice than using `kill -9`.
Still looking how to pinpoint the dtwm process to terminate.
thanks,
Boyd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 06:35 AM
08-28-2000 06:35 AM
Re: How to determine a particular process on a particular box
This program lists all run processes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 06:47 AM
08-28-2000 06:47 AM
Re: How to determine a particular process on a particular box
When a user logs in set a variable in their .profile/.dtprofile which is their DISPLAY (IP address), if this is from an X session then DISPLAY should be set by default, else use it from who -u. Now that session knows its own IP so later if you need to restart their dtwm process you know which one to kill.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 12:52 PM
08-28-2000 12:52 PM
Re: How to determine a particular process on a particular box
#!/bin/sh
this_pid=$$
orig_pid=$$
command=""
while [ "`basename $command`" != "dtsession" ]
do
ps -ef | awk '( $2 == '"$this_pid"' ) { print $3, $8 }' | read ppid command
orig_pid=$this_pid
this_pid=$ppid
done
kill -s SIGKILL `ps -ef | awk '( $3 == '"$orig_pid"' && $8 == "dtwm" ) { print $2 }'`
dtwm &
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2000 06:05 AM
08-30-2000 06:05 AM
Re: How to determine a particular process on a particular box
# lsof -u rbeldin | grep 6000
dtterm 1869 rbeldin 4u inet 0x40ef0c68 0t1931356 TCP wallace:49534->rbeldin3107.atl.hp.com:6000 (ESTABLISHED)
dtterm 3514 rbeldin 4u inet 0x40ff6868 0t802704 TCP wallace:61128->rbeldin3107.atl.hp.com:6000 (ESTABLISHED)
Xnest 3723 rbeldin 6u inet 0x40d5b668 0t1533916 TCP wallace:61499->rbeldin3107.atl.hp.com:6000 (ESTABLISHED)