The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-17-2008
era
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
If I understand you correctly, you want to run a new ssh command every three seconds, regardless of the fact that the previous ssh command could have taken more than three seconds to complete? So run them in the background.

Code:
while true; do
  ssh user@domain echo a &
  sleep 3
done
The "&" there runs the command in the background.

I assume that "echo a" is the command you want to run on the remote server, and that you had the syntax for this wrong (too).

Unless you are running a real-time operating system, there is no guarantee that "sleep 3" will not take more than 3 seconds, of course.

Edit: Upon rereading your question, I guess that the real problem was really how to pass the remote command to the server over ssh. Well, I coincidentally seem to have answered that, too. If you don't want the ssh to run in the background, just take out the "&".