logoff idle user script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers logoff idle user script
# 1  
Old 05-09-2002
Question logoff idle user script

Will someone please share a script with me that will read in each line of the who -u output and if idle time is more than 50 min, execute a kill on the PID? This is what I have so far:

who -u | cut -c 40-56

I am comfortable in the korn shell, but I can broaden my horizons if you've got something fabulous. Any help would be greatly appreciated.
# 2  
Old 05-09-2002
If you do a search for kill and idle, you should find that there are scripts posted already such as
thehoghunter
# 3  
Old 05-09-2002
And personnally, I would go with
who -u |awk '{print $1" "$6}'
to get both the idle time and who it belongs to.

Be careful of duplicate sign-ons, root account, cron jobs, ....
thehoghunter
# 4  
Old 05-14-2002
I did the search before. I guess I was using the wrong keywords or something. Thanks for your help! I'll try these...
# 5  
Old 05-24-2002
Autologout... this worked

Stopudt is a unidata (database) command that issues a kill -15 I believe to let things finish writing.


#!/usr/bin/ksh
#
# Logs users out that have been idle for 20 or more minutes.


UDTBIN=/usr/ud51/bin
UDTHOME=/usr/ud51

export UDTBIN
export UDTHOME


/usr/ud51/bin/stopudt `who -u | sed -e "s/\./0/" -e "s/://g" | awk '$6 > 20 {pri
nt $7}'`
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

2. Shell Programming and Scripting

Case Statement for Login/Logoff Script

I'm currently trying to write a login script. I have already written a logoff script that uses an if/else statement. #!/bin/bash TIMED=$(date +%H) if ' then echo Have a Great Day $USER else echo Have a Great Night $USER fi But I'd like to write one that give me the option of... (1 Reply)
Discussion started by: bbowers
1 Replies

3. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

4. Shell Programming and Scripting

Logon/Logoff script

I need help for writing a logon/logoff script for recording user's computer usage time. This is for local login only, not for ssh or something like that. When a user logon, there should be a temp file (/home/acct/login_temp) generated including the logname and logon time information in the... (8 Replies)
Discussion started by: jimx
8 Replies

5. AIX

Track user logoff in AIX 5.3

Hi Does anybody know if there is a way in AIX 5.3 to track how a user was logged off? For instance where the user typed exit, hit crtl D, shell process was killed, etc. I know of the last log entries but this just shows a users login time and duration. I also tried syslog but I only get login... (5 Replies)
Discussion started by: kimyo
5 Replies

6. UNIX for Dummies Questions & Answers

determine if user is truly idle

I have a problem. I made a script (that I am very proud of - never scripted before) that kills off idle sessions based on who -u. The problem is it is killing sessions that aren't truly idle. who -u reports them as being idle for 7 hours, when in reality they have been using a program for that... (5 Replies)
Discussion started by: raidzero
5 Replies

7. Shell Programming and Scripting

User Idle Time

Does anyone know how do you determine the user idle time of stdin in order to log the user out for being idle too long. I would like to write a c program to do this but I it is not clear upon how to determine idle time from keyboard input. (9 Replies)
Discussion started by: cpaquette
9 Replies

8. UNIX for Advanced & Expert Users

Running a script during logoff

I know we can put whatever we need to run during login inside /etc/profile or .profile file. I want to run a set of commands before logoff. Where should I put my commands/scripts? Is such facility available? (3 Replies)
Discussion started by: praveenkumar_l
3 Replies

9. AIX

Logoff a user...

Hi... could anyone tell me how to kill a user session on my server with out affecting other user? Bala (6 Replies)
Discussion started by: balaji_prk
6 Replies

10. UNIX for Dummies Questions & Answers

logoff ghost user

I just noticed by running a who command that I was logged in twice . So two admin2 are on the list. (solaris 2.6) Since I telnet using a windows 98, I suppose that I forgot to CTRL-D last time I logged in and clicked on hangup. In such a case, how can I loggoff the old ghost loggin ? It's not a... (4 Replies)
Discussion started by: phpote
4 Replies
Login or Register to Ask a Question