-2

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.

marked as duplicate by Jeff Schaller, mdpc, Raphael Ahrens, Scott, Anthon May 13 '16 at 5:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 5: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). – roaima May 13 '16 at 8:13
2

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 #...
  • 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.

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