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.