有没有办法让 root shell '超时'(例如, in gnome-terminal
),以便在一定时间后不发出任何命令,shell 退出?
我正在寻找一个适用bash
于 Fedora 和ksh
OpenBSD 的解决方案。
答案1
您可以将该变量设置TMOUT
为您希望 bash 在没有命令运行时自动注销 shell 之前等待的秒数。
答案2
我知道这个问题是关于 Bash 和 Ksh 的。但我想我应该为 csh/tcsh 发布类似的内容以供记录。
在 FreeBSD 上,默认 shell 是 tcsh。您可以使用autologout
tcsh shell 的功能自动注销会话。
以下将在闲置活动一分钟后自动注销会话。
freebsd82# set -r autologout=’1′
(Wait one minute)
freebsd82# auto-logout
Connection to freebsd82 closed.
这tcsh(1)联机帮助页是这样描述的:
autologout (+) The first word is the number of minutes of inactivity before automatic logout. The optional second word is the number of minutes of inactivity before automatic locking. When the shell automatically logs out, it prints `auto-logout', sets the vari- able logout to `automatic' and exits. When the shell automati- cally locks, the user is required to enter his password to con- tinue working. Five incorrect attempts result in automatic logout. Set to `60' (automatic logout after 60 minutes, and no locking) by default in login and superuser shells, but not if the shell thinks it is running under a window system (i.e., the DISPLAY environment variable is set), the tty is a pseudo-tty (pty) or the shell was not so compiled (see the version shell variable). See also the afsuser and logout shell variables.