Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have here a read only Bash variable. I am not allowed to unset that variable.

$ echo $TMOUT
1800

As a workaround I wrote those lines (that my session don't exit)

#!/usr/bin/perl

$|++;
while (1) { print "\e[0n"; sleep 120; }

Is there an official package (rpm) that does similar (like above Perl code) in a CentOS7/RHEL7 repository? I don't like to open up a vim editor, I wish a command.

share|improve this question
    
Usual solution to this is just run cat when stepping away from your session. And then ^C it on your return. – steve Aug 10 '15 at 14:36
    
I imposed a similar rule because I had people in my team that left terminals open for weeks in a row. Whilst I do agree 1800 is kinda of low, it must be there for some reason. People tend to notice deviations to the usual...yours sessions will stand out like a sore thumb. – Rui F Ribeiro Jan 29 '16 at 9:04
up vote 3 down vote accepted

You can issue perl commands from the command line...

perl -e '$|++; while (1) { print "\e[0n"; sleep 120; }'

or you could do the same in shell (a sh/bash example):

while sleep 120; do printf '\33[0n'; done

Or you could use watch:

watch -n 120 printf '\33[0n'

share|improve this answer

Add this to the start of your .bash_profile ?

if [ ! -z "$TMOUT" ]; then
  env -i bash --init-file ~/.bash_profile
fi

Beware the wrath of the sysadmins if you leave a gazillion old sessions running as a result of defeating their timeout rulings.

share|improve this answer

Why aren't you switching to non-interactive session?

# TMOUT=0
-bash: TMOUT: readonly variable
# unset TMOUT
-bash: unset: TMOUT: cannot unset: readonly variable
# su
# export TMOUT=10
# unset TMOUT
# 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.