PIKT

Samples: Kill Idle User Sessions

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


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.

///////////////////////////////////////////////////////////////////////////////
//
// process_alarms.cfg
//
///////////////////////////////////////////////////////////////////////////////

[other alarms omitted...]

///////////////////////////////////////////////////////////////////////////////

KillIdleUserSession

        init
                status active
                level critical
                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}'`"

///////////////////////////////////////////////////////////////////////////////

[other alarms omitted...]

///////////////////////////////////////////////////////////////////////////////

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

Automating Unix and Linux Administration
Automating Unix and Linux Administration

The Linux Enterprise Cluster
The Linux Enterprise Cluster

Linux Cookbook
Linux Cookbook

Red Hat Linux 9 for Dummies
Red Hat Linux 9 for Dummies

SuSE Linux Enterprise Server 9 Administrator's Handbook
SuSE Linux Enterprise Server 9 Administrator's Handbook