I wrote a script to kill users idle more than 1/2 hour, ignoring those in an exception list. Here is the script as it is now:
#! /usr/bin/awk -f
BEGIN {
system("who -u | sort +5 > /tmp/loginfile");
system("echo User Sessions Killed > /tmp/killedlogins");
system("echo `date` >> /tmp/killedlogins");
while (getline < "/tmp/loginfile") {
split($6,timearray,":");
if (((timearray[1] == "old") || (timearray[1] >= 1) || (timearray[2] >= 30)) &&
($1 != "Exclusion1") &&
($1 != "Exclusion2") &&
($1 != "Exclusion3") &&
($1 != "Exclusion4")) { {
system("kill -9 " $7);
print $1, "[Idle " $6 "] Session terminated from " $8 >> "/tmp/killedlogins";
};
};
system("rm /tmp/loginfile");
system("chmod 644 /tmp/killedlogins");
}
This works fine until one of the excluded users is idle until they become "old". How can I change this so that it still terminates users after 30 minutes and still ignores people on the exclusion list but only until they become "old" and then terminate them too?
Thanks