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}'`"

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 2018-01-02.   This site is PIKT® powered.
Copyright © 1998-2018 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
See how to
report high system
load averages