0

Is there a way I can automatically kill a Bash console after it is idle for a specified period of time?

Dull Bananas
  • 183
  • 1
  • 5

1 Answers1

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