{ 6 comments… read them below or add one }

1 yoander 02.25.09 at 2:58 pm

nice tip

2 Liju 02.25.09 at 3:19 pm

Good tips .. :-)

3 marz 02.25.09 at 9:23 pm

while date ; do sleep 10 ; done

or

watch -n 10 date

;)

4 Boopalan 03.07.09 at 2:49 am

i wont hardware networking /linux /ccna

5 MikeM 03.31.09 at 4:55 pm

We wanted something a bit more user explicit (log out idle users but not the boss(s)). The list of users below are exempt. Set this script in crontab to run every 10 minutes. With an idle of time of 30, the idled sessions will be no more than 39 minutes idle.
Here is our script;

#! /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 = 1) || (timearray[2] >= 30)) &&
($1 != "root") &&
($1 != "user2") &&
($1 != "user2") &&
($1 != "user4") &&
($1 != "lastuser")) { {
system("ps -ef | grep " $1 " | awk '{print $2}' | xargs kill -KILL");
print $1, "[Idle " $6 "] Session terminated from " $8 >> "/tmp/killedlogins";
};
};
};
}
6 Vivek Gite 03.31.09 at 8:15 pm

@MikeM

Thanks for sharing your script.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All