kill all idle user processes
Hi, all the kill idle user processes scripts I've seen don't take into account that the user might have multiple sessions open. Such is the case with one of our clients. Currently, every hour or two I need to do the following:
This will get the TTY and idle time for all users.
w |grep pts/ | tr -s ' ' | cut -d " " -f2,5
For each idle time over a half hour, I do the following (TTY is the TTY from the previous command with a space ("$TTY ")):
ps -ef |grep TTY | tr -s ' ' | cut -d " " -f2
I then kill those processes.
There must be a way to do this automatically in a bash or perl script. I've tried both, but can't seem to get things to work properly.