1

I'd like to get a Linux command which runs in the background and writes something to the terminal screen every one minute. I am trying to keep ssh session alive, I am using Cygwin for connection to the server but the connection is resetting every short time if nothing is written to the screen.

I already tried with sshd_config option to solve the short connection time by changing ServerAliveInterval 0 to ServerAliveInterval 60 but this does not solve the problem.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • I am trying to keep ssh session alive, I am using Cygwin for connection to the server but the connection is resetting every short time if nothing is written to the screen. – Mohsen El-Tahawy May 12 '16 at 21:45
  • Why do you want to keep your ssh session alive? You can use nohup to keep your program running and just pipe the output to a file. – orezvani May 12 '16 at 23:56
  • In "It doesn't work", what does "it" refer to? What you tried to change in sshd_config? If you want to solve this properly, provide some more detail we might point you to what you are doing wrong. – Anthon May 13 '16 at 05:17
  • Setting ServerAliveInterval in the sshd_config file is pointless (it's a client-side option). I suggest you re-read the answers in the duplicate question (particularly the accepted answer). – Chris Davies May 13 '16 at 08:13

2 Answers2

4

There's watch, loops with sleep, crontab, and many other options:

watch -n 60 echo hello world


while :; do echo hello world; sleep 60; done


crontab -e #...
Petr Skocik
  • 28,816
  • 1
    You omitted the trivial solution: Just type in the command every 60 seconds and press "Enter." ;) – Wildcard May 12 '16 at 23:05
1

I agree this might be a duplicate of the question linked, but there are times when those options in the sshd_config just don't work.

In those situations, I use tmux on the target server with a lower status bar which has the time in it, updated every 15 seconds.

EightBitTony
  • 21,373