linux 查杀空闲很久的用户,在Linux中,如何在用户空闲期之后退出日志记录,即使他们仍然在程序中...

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.

我正在尝试执行一个策略,该策略将空闲用户从bash shell会话中记录下来,即使他们处于一个活动进程中,比如基于脚本的菜单或vi会话。

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.

我尝试过使用“export TMOUT=x”,其中x是秒数,但是只有当用户在bash shell提示符下空闲时,这才会记录用户。

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?

是否有一个bash脚本或任何我可以运行的C代码来检查哪些用户已经闲置了太长时间,然后停止该用户运行的所有进程,并将它们注销?

Thanks

谢谢

Ryan

瑞安

1 个解决方案

#1

4

in bash

在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).

为每个shell提供用户名/idletime对。您可以使用此信息设置cronjob以注销正确的人员。空闲时间是自shell中最后一次击键以来的时间(而不是应用程序)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值