- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: kill all the process of a particular 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
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-13-2004 11:36 AM
тАО10-13-2004 11:36 AM
kill all the process of a particular user
Thanks in advance
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2004 11:41 AM
тАО10-13-2004 11:41 AM
Re: kill all the process of a particular user
As far as a script is concerned, there are plenty shoudl you do a search. Here is one sample that has some.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?admit=716493758+1097710814724+28353475&threadId=250406
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2004 11:48 AM
тАО10-13-2004 11:48 AM
Re: kill all the process of a particular user
# vi /usr/local/bin/kill-all.sh
#!/usr/bin/sh
if [ $# -lt 1 ]
then
echo "Usage: kill-all.sh
exit 1
fi
USER=$1
ps -fu $USER 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "User $USER is unknown or do not own any process in the system"
exit 0
else
ps -fu $USER | grep -v UID | awk '{print $2}' | xargs -n1 kill
sleep 5
ps -fu $USER | grep -v UID | awk '{print $2}' | xargs -n1 kill -9
if [ $(ps -fu $USER | grep -v UID | wc -l) -gt 0 ]
then
echo "Could not successfully kill all the user's processes"
exit 1
else
echo "Successfully killed all the user's processes"
exit 0
fi
fi
#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 12:46 PM
тАО10-14-2004 12:46 PM
Re: kill all the process of a particular user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 07:02 PM
тАО10-14-2004 07:02 PM
Re: kill all the process of a particular user
We can do with a one line script as,
kill -9 `ps -u
If you want to kill process related to user and more based on terminal type then,
we can collect terminal information + user with who -Ru command there. We can also kill user based on their remote login IP there.
We can get the specific users commands execution with their history file there. You can collect that history file as,
FILE=$(su
echo "Command usage by
cat $FILE
We have to have root permission to do this with out problem / passwd prompting there.
By combining both,
#!/bin/sh
echo "Enter username to be killed and monitored"
read user
kill -9 `ps -u $user | grep -v 'PID TTY' | awk '{ pritn $1 }'`
cat `su $user -c "echo $HISTFILE"`
# end #
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 07:41 PM
тАО10-14-2004 07:41 PM
Re: kill all the process of a particular user
#ps -ef|grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 07:56 PM
тАО10-14-2004 07:56 PM
Re: kill all the process of a particular user
another soultion would be
for i in `ps -fu
do
(echo $i)
kill (-9) $i
done
Regards
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:28 PM
тАО10-14-2004 08:28 PM
Re: kill all the process of a particular user
kill -9 `ps -aef | grep USERNAME | grep -v grep | awk '{ print $2 }'`
replace USERNAME with the name of the user who you want to kill.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:48 PM
тАО10-14-2004 08:48 PM
Re: kill all the process of a particular user
# kill $(UNIX95= ps -u $USER -o pid=)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 09:18 PM
тАО10-14-2004 09:18 PM
Re: kill all the process of a particular user
kill -9 -1
Don't try this with root or other UID0-users :-)