Log out an interactive Bash after 900 seconds without input at a prompt.
Prevent the same shell from changing the value.
Which setting is appropriate?
TMOUT is the interactive Bash idle timeout in seconds. readonly prevents changes or unsetting in that shell.
Detailed explanation
export IDLE=900Incorrect. IDLE is not Bash's special timeout variable.
readonly TMOUT=900Correct. readonly TMOUT=900 sets and protects the timeout.
timeout 900 bashIncorrect. timeout limits total child-process runtime, not prompt idleness.
sleep 900; exitIncorrect. sleep then exit ignores whether the user enters input.
Try it yourself
An example you can run in a temporary verification environment.
bash -c 'readonly TMOUT=900; printf "value=%s readonly=%s
" "$TMOUT" "$(readonly -p | grep -c "TMOUT=")"'Expected result
value=900 readonly=1Key points
- TMOUT is seconds
- Interactive prompt timeout
- readonly prevents changes
Notes
- Environment: Bash 5.x / 自動logout待機は行わない
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Permission bit
A mode bit controlling read, write, execute, or special execution behavior.
Account state
Attributes that determine whether a password or login account can be used.
Resource limit
A per-process or per-user ceiling such as open files or process count.