1753620 Members
6316 Online
108797 Solutions
New Discussion юеВ

TMOUT cause scripts end?

 
SOLVED
Go to solution
Fernando Boza
Regular Advisor

TMOUT cause scripts end?

In the company where I work, run some scripts that typically take an hour to complete.
It is going to set the variable TMOUT in /etc/profile with a value of 600 (10 minutes)

This setting will cause the script ends earlier than expected?
10 REPLIES 10
Fernando Boza
Regular Advisor

Re: TMOUT cause scripts end?

This configuration also SFTP session ends?
Deeos
Regular Advisor

Re: TMOUT cause scripts end?

Hi,



you can put # in the entry of TMOUT veriable line, so it will be visual at the end of script execution!



Regards
Deeos
Deepak
Raj D.
Honored Contributor

Re: TMOUT cause scripts end?

Fernando,

You can put a larger value of TMOUT in the user local .profile , or you can use in your script :

export TMOUT=50000

something large value.
And the timeout would not happen.

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Steven Schweda
Honored Contributor

Re: TMOUT cause scripts end?

Why not run the experiment? In about ten
minutes, you should know the answer. (And
that method is more reliable than looking for
opinions here.)

> [...] set the variable TMOUT in
> /etc/profile [...]

For experimental purposes, you could set it
locally instead of for everyone.
Dennis Handly
Acclaimed Contributor

Re: TMOUT cause scripts end?

>This setting will cause the script ends earlier than expected?

No, in a real shell, TMOUT only checks idle shells, not scripts that are eating up CPU.
James R. Ferguson
Acclaimed Contributor

Re: TMOUT cause scripts end?

Hi:

Aside from experimenting (which is a great way to learn), there is always the quick look at the manpages. In this case, the 'sh-posix(1)' manpages in the section about parameter substitution states that if TMOUT is "...set to a value greater than zero, the shell will terminate if a command is not entered within the prescribed number of seconds after issuing the PS1 prompt."

Regards!

...JRF...
Bill Hassell
Honored Contributor
Solution

Re: TMOUT cause scripts end?

TMOUT has no meaning inside a running shell script. Your login (interactive) shell starts counting seconds when it displays the command line prompt (ie, $ or #, whatever). When you run a script or a program (like vi), the counter does not run. When the script or program ends, the counter starts over from zero.

So TMOUT is only meaningful when the shell is waiting for a user to type something. It is safe to set it in /etc/profile although 600 (10 minutes) seems a bit short. Users may be on a phone call and their idle session will terminate. Sysadmins will be particularly annoyed when troubleshooting problems and talking with users and their sessions terminate.

NOTE: Any user can change TMOUT to a larger number (or zero) in their own profile unless you make the TMOUT variable readonly.


Bill Hassell, sysadmin
Fernando Boza
Regular Advisor

Re: TMOUT cause scripts end?

Thanks to all

Bill, you are right!!!


Another question:

What happend with SFTP conections?
Bill Hassell
Honored Contributor

Re: TMOUT cause scripts end?

> What happend with SFTP conections?

I am assuming you mean: will SFTP connections timeout? The answer is no. SFTP, like rcp, ftp, rsync, etc, are just programs that can be started from a shell prompt. Once the new program starts (like SFTP), the shell stops running and does nothing until the kernel wakes up the shell. If the shell is not running, then the TMOUT counter is not running either. TMOUT is *only* for shell logins that are waiting at a prompt.


Bill Hassell, sysadmin