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.
Incorrect. IDLE is not Bash's special timeout variable.
readonly TMOUT=900Correct. readonly TMOUT=900 sets and protects the timeout.
Correct. readonly TMOUT=900 sets and protects the timeout.
timeout 900 bashIncorrect. timeout limits total child-process runtime, not prompt idleness.
Incorrect. timeout limits total child-process runtime, not prompt idleness.
sleep 900; exitIncorrect. sleep then exit ignores whether the user enters input.
Incorrect. 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
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.