script for killing idle users

I need a script that will look for idle users and kill there proc.

And what code have you written so far in attempting to solve this problem?

You're lucky I'm bored!

Hers something I whipped up in a few minutes, suggestions?

#!/bin/bash
# kill off users idle for 1 or more days
# 12/16/2005 - kefx

IUSERS=`w | awk '/[1-9]day?/ {print $1}'`

for i in $IUSERS
do
pkill -U $i
done

exit 0

actually --- your script only kills user logins that are longer than 1 day --- it does not differentiate between users who are actively working and users who are are not actively working

Can't say I undestand what you mean. If they were actively working they would not have an IDLE listing over 1day or more under 'w'. To my knowledge...

see this ...

if a user has been logged in for over a day and had just finished running a long script and then took a minute to read some notes for the next script --- your script will kill his login when it runs because it does not see when he last did anything on the server

Yeah, I see what you mean.

set this variable in the /etc/profile to that of seconds that a login can be left alone if inactive.

works in AIX 5.2. Not sure if it is available in other NIXes.

jerardfjay