- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to kill all the process belongs to a user
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
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
тАО05-11-2009 11:39 AM
тАО05-11-2009 11:39 AM
I want kill to all the process in single command that belongs to particular user.
Normally i am killing the process using PID. so it takes time to kill all the process. since one use can start N number of process.
so it will be usefull if i am able to kill all the process run by a user.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 11:48 AM
тАО05-11-2009 11:48 AM
Re: how to kill all the process belongs to a user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 12:06 PM
тАО05-11-2009 12:06 PM
Re: how to kill all the process belongs to a user
If you really want to do this, one way is:
# UNIX95= ps -fu uid -o pid=|xargs -i kill {}
Note that 'uid' in the above command can be either a 'uid' or a username.
The UNIX95 environement is set _only_ for the command line. There is no semicolon after the "=" character and before the 'ps' command.
This command creates a list of all the process IDs (pid) associated with a user (uid) and pipes them to the 'kill' command as a list.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 12:39 PM
тАО05-11-2009 12:39 PM
Re: how to kill all the process belongs to a user
I should add the following admonishment. Do not begin with a 'kill -9'. A kill -9 cannot be trapped by a process and thus the process has no chance to cleanup temporary files or remove shared memory segments. This is quite undesirable.
Instead, perform a series of 'kill' actions.
Capture your pid list in a variable as:
# PIDS=$(UNIX95= ps -u uid -o pid=)
...where 'uid' is the user name or 'uid' value of interest.
Now do:
# kill -1 ${PIDS}
# kill -15 ${PIDS}
# kill -9 ${PIDS}
This leaves a 'kill -9' as the last resort only.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 12:56 PM
тАО05-11-2009 12:56 PM
Re: how to kill all the process belongs to a user
for i in `ps -u
>do
>kill -9 $i
>done
Like it or worked !! Click kudos !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 12:59 PM
тАО05-11-2009 12:59 PM
Re: how to kill all the process belongs to a user
that will list all the process by a user from that o/p extract the process ID and then kill them.
I know you can figure out a better way than me.
Cheers,
uvk
Like it or worked !! Click kudos !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2009 02:31 PM
тАО05-11-2009 02:31 PM
Re: how to kill all the process belongs to a user
Although it is probably obvious, when you use the 'kill' sequence I suggested, you will probably want to suppress the warning "The specified process does not exist" for processes that have been terminated by the first or second 'kill'. Thus:
PIDS=$(UNIX95= ps -u uid -o pid=)
kill -1 ${PIDS}
kill -15 ${PIDS} 2>/dev/null
kill -9 ${PIDS} 2>/dev/null
You could also test for an empty list first as:
PIDS=$(UNIX95= ps -u uid -o pid=)
if [ ! -z "${PIDS}" ]; then
kill -1 ${PIDS}
kill -15 ${PIDS} 2>/dev/null
kill -9 ${PIDS} 2>/dev/null
fi
...or you could skip the empty list test and also redirect STDERR to /dev/null for every 'kill' so that an empty list doesn't give an error like: "The number of parameters specified is not correct".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2009 03:58 AM
тАО05-12-2009 03:58 AM
Re: how to kill all the process belongs to a user
Do the below things
ps -aef | grep username
take the pid's of all process
right a for loop to kill those pid's
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2009 08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2009 10:36 PM
тАО05-12-2009 10:36 PM
Re: how to kill all the process belongs to a user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 06:08 AM
тАО05-13-2009 06:08 AM
Re: how to kill all the process belongs to a user
...You should _re-read_ what I told you about capriciously using 'kill -9'...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 08:22 AM
тАО05-13-2009 08:22 AM
Re: how to kill all the process belongs to a user
#ps -ef | grep username --> this will also give u a process where the username and processname are the same
You should use
#ps -u
so the single line command can be
#ps -u
Like it or worked !! Click kudos !!