Kill Idle User Sessions

In this example, we kill idle user sessions--inactive user logins.

The KillIdleUserSession script shown below does its work silently, and sends no alert messages.  You could add rules to send alert messages, if you want to.  (Also note that all kill commands are always logged.)

The script follows.

KillIdleUserSession

        init
                status =piktstatus
                level =piktlevel
                task "Terminate idle user sessions"
                input proc "\=w | \=awk '/[1-9]days/ {gsub("/","\\\\/");
                                         print $1 " " $2}'"
                dat $user 1
                dat $tty 2

        rule
                exec wait "\=kill -9 `\=ps -aux |
                           \=awk '/$user.+$tty/ {print \$2}'`"

Open Hand For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
runaway processes
Pikt script