Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • You don't want to export TMOUT. That would affect the read builtin of all bash or ksh93 script started from your login session. Commented May 24, 2016 at 16:25
  • @StéphaneChazelas yes, isn't that what the OP wants? If they want their session to exit after 10 minutes, they also, presumably, want their scripts to exit as well. They will be killed when the session ends in any case, after all. Commented May 25, 2016 at 9:23
  • TMOUT on read doesn't cause scripts to end, it causes read to fail after a timeout, which could make scripts fail in every possible way. It's unlikely to cause problems as it would be rare for read to hang for 10 minutes, but it's still wrong to export TMOUT (also note that once exported, if a script does TMOUT=1 it will affect all scripts called from within that script instead of just the script itself). Commented May 25, 2016 at 9:50
  • @StéphaneChazelas OK. Simply setting it would be OK and should still do what the OP needs though, right? Commented May 25, 2016 at 9:55
  • Yes, though then I'd probably do it in ~/.bashrc so it affects all interactive shells, not only the login one (and assuming ~/.profile or ~/.bash_profile sources ~/.bashrc as one need to do to work around that bash bug). tty | grep -q 'tty[0-9]' to avoid considering ttyUSB3 or ttyS1. Commented May 25, 2016 at 10:18