Bash – Workaround for Read-Only TMOUT Variable to Prevent Auto Exit

bashenvironment-variablesreadonlytimeout

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.

Best Answer

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'

Related Question