Is there a way I can automatically kill a Bash console after it is idle for a specified period of time?
Asked
Active
Viewed 507 times
0
-
Possibly related: https://unix.stackexchange.com/q/4126/237982. What do you mean by console? – jesse_b May 31 '19 at 17:43
-
2There's also TMOUT (https://unix.stackexchange.com/a/245117/117549) – Jeff Schaller May 31 '19 at 17:44
1 Answers
1
My suggestion would be to set the TMOUT variable to a nonzero value. If users attempt to override it, set it readonly in a global profile script.
TMOUT
If set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin (see Bash Builtins). The select command (see Conditional Constructs) terminates if input does not arrive after TMOUT seconds when input is coming from a terminal.
In an interactive shell, the value is interpreted as the number of seconds to wait for a line of input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if a complete line of input does not arrive.

Jeff Schaller
- 67,283
- 35
- 116
- 255