Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

Idle User's timeout

kemo
Trusted Contributor

Idle User's timeout

Hello

In tru64 5.1b, latest patch kit. informix installed. some users login to the server and leave the informix Application, which is running automatically once the user logs in, Idle for hours. i want to kill whoever doing that.

in "w" command output, IDLE is showing the IDLE time for each user. but i am not able to do any script which can AWK that column and killing that user's processes.

can you help me doing that?

thanks
6 REPLIES
Steven Schweda
Honored Contributor

Re: Idle User's timeout

> can you help me doing that?

It might be easier if we could see some of
your "w" command output.

Note that some shells use a TIMEOUT or TMOUT
variable to control auto-logout.
kemo
Trusted Contributor

Re: Idle User's timeout

Hello

w output is not fixed. it keeps vary rapidly with user activity.

TMOUT and TIMEOUT is for idle users which has no running process at all. but in our case, i have a running application as i mentioned above.

thanks
kemo
Trusted Contributor

Re: Idle User's timeout

this is what i did.

put this in a file, chmod it to executable, create a cron entry in crontab every 2 hours to execute this script.


################ kill users with more than 1 hour idle ###############
for hours in `who -u | awk -F " " '{ print $6"-"$7 }' |grep :`
do
echo $hours>/tmp/hours
idle=`awk -F "-" '{ print $1}' /tmp/hours | awk -F ":" '{ print $1 }'`
ID=`awk -F "-" '{ print $2}' /tmp/hours`
if [ $idle -ge 1 ]
then
echo "$ID will be killed"
kill -9 $ID
fi
done
###############################################################
thanks
kamal
Steven Schweda
Honored Contributor

Re: Idle User's timeout

> w output is not fixed. [...]

I was hoping for a sample, not everything for
all time.

> kill -9 $ID

"kill -9" is not the first thing I'd try.
kemo
Trusted Contributor

Re: Idle User's timeout

Hello

thanks for your comment, it will be so appreciated if you share us any other idea.

thanks
kamal
Steven Schweda
Honored Contributor

Re: Idle User's timeout

> [...] any other idea.

Before I hit a process over the head with the
big club ("kill -KILL"), I'd start with
something a little more gentle, like, say,
"kill -TERM", then wait a few seconds, and
see it it's still there.

I know nothing about your "informix
Application", but some programs will die more
cleanly if you ask them nicely.

If the gentle method fails, _then_ I'd fall
back to using the big club.