开发者

In Linux, how do I log a user out after idle period, even when they are still in a program

I am trying to enforce a policy that logs an idle user out of a bash shell session, even when they are in an active process like a script-based menu, or vi session.

I 开发者_运维百科have tried using "export TMOUT=x" where x is the number of seconds, but this only logs a user out if they are idle at the bash shell prompt.

Is there a bash script or any C code that I can run that will check what users have been idle for too long, and then stop all processes run by that user, and log them out?

Thanks

Ryan


in bash

w | tr -s " " | cut -d" " -f1,5 | tail -n+3

gives you a username/idletime pair for each shell. you can set up a cronjob using this information to logout the correct people. The idletime is the time since the last keystroke directly in the shell (and not the applications).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜