- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to kill users
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
Forums
Discussions
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
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
04-28-2004 04:21 PM
04-28-2004 04:21 PM
how to kill users
Our ERP clients connects server using telnet over the WAN. If in between connection drops user session hungs inbetween.
How can I schedule that system should check the users who are inactive from last 30 or more minutes and kill that ID's automatically.
HP Unix version is 11i.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 04:28 PM
04-28-2004 04:28 PM
Re: how to kill users
1. # w
this output will give who all are logged in.
2. # cut
Use this command to get Value of Idle field from the ouput
3. Repeat same to get ttty no of the same.
4. # ps -t
This will list all the processes fo that user with PID
5. # kill -9
Kill all processes using this along with shell process for that particular user and your user is logged out.
Hope this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 04:31 PM
04-28-2004 04:31 PM
Re: how to kill users
# crontab -e
Use this command to put your shell script in CRON for scheduling its execution.
see man cut, man ps, man contab if required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 04:37 PM
04-28-2004 04:37 PM
Re: how to kill users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 07:03 PM
04-28-2004 07:03 PM
Re: how to kill users
Maybe you're in the wrong forum ;-)
Perhaps you can set TMOUT=1800 in /etc/profile (look in manpage of sh or ksh).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 12:38 AM
04-30-2004 12:38 AM
Re: how to kill users
TMOUT=300 # Time out in 5 minutes
export TMOUT
Unfortunatlly, I think this only works if the user is truly idle. If they are running a menu program or editor or some such thing, even though they may not be doing any I/O, I don't think they will be logged out, but I could be wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 01:04 AM
04-30-2004 01:04 AM
Re: how to kill users
ps -ft pts/ta
where pts/ta (or perhaps ttyr3) is the tty device mentioned in w. The login shell will always end with a - as in: sh- or ksh- and that is the process to kill. If you use w -l, then you'll get the top-level process as the last field. To extract the last process name, you'll have to use awk's NF value since the number of fields in w variesd because of null information.
Be very careful with testing your shell script: always exclude root since you may kill an important process someone is running, and also be careful that a particular process that someone may be running should not be killed...that is application dependent.
As mentioned, TMOUT can be used to expire the shell, but only is the shell is running. If a user runs a process like vi, vi will never terminate if the user walks away and the shell will never run.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 01:27 AM
04-30-2004 01:27 AM
Re: how to kill users
If you are using database then you must first kill the process involved in that. First kill from database end and then kill from unix end. Though kill -9 is not recommended first, you first choose -15 option and then -9. Here is the script which can help you.This scrip will kill users who are idle since 30 to 59 minutes. Keep it in cron or run manually.
who -u |grep query| cut -c 1-10,39-50| grep -e "[0]:[30-59]" > current
for i in `cat current | awk '{print
$3}'`
do
kill -15 $i
kill -9 $i
$i
done
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 09:30 AM
04-30-2004 09:30 AM
Re: how to kill users
But I have thought that is worth discussing.
who -tu has the following output:
rory pts/3 Apr 30 08:41 1:33 18310 rrhammond:0.0
fuser -uk /dev/pts/3
kills all of the process associated with that login.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 07:24 PM
04-30-2004 07:24 PM
Re: how to kill users
KIll -9 pid is vary bad practice, and will certainly leave accounting connections open if you use the w command.
Kill -15 pid is the better option and more tidy!
TMOUT in the profile sounds good for shell sessions but not always practical for db applications that may want the db connection closing in a more desirable method.
The best method for accuracy & control is to perform the kill manually, unfortunately this can be laborious and not the answer you are looking for.
Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2004 02:40 PM
05-02-2004 02:40 PM
Re: how to kill users
Thanx for your response to my query. I got the perfect ans for my query. I want to share it with you. I am using the following command to kill users who are ideal.
/usr/bin/who -u | /usr/bin/awk '{print $6" "$7}' | /usr/bin/grep 0:[345] | /usr/bin/awk '{print "/usr/bin/kill -9 "$2}' | usr/bin/sh
Regards
Rajesh