Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with ssh command not ending from cron

Status
Not open for further replies.

kymlyons

Technical User
Jun 3, 2004
2
US
Hi,

I'm looking for help with a script I wrote that is being executed from a cron job. I use the ssh command to do a directory on a remote host and write it to a file on the host the script is running on. The command I use is:

ssh usename@remotehost "ls /dirname/*" >/dir_on_script_host/filename

The ssh command works fine and I always get my file on the script host, however sometime the command just does not end? Thus the script is stopped at that spot. I'm assuming there is some kind of race condition happening with what ssh is looking for to end the session. If I kill the ssh command left suspended on either the remote host or the script host all is find and the script keeps going.

I am going to try running the command in the background for now and just look for it to still be running after sometime and kill it if so but I really don't like this method and would like to do something cleaner.

Any ideas would be great thanks!
Kym
 
I can't remember the exact arguments, but you need to specify that SSH is running batch mode. I don't think this is covered in the man page (if you're running F-Secure's SSH), so do some Googling and you'll find the correct way of doing it.
 
batch mode disables prompts, which may be the problem:

ssh -o "BatchMode yes" username@remotehost "ls /dirname/*"



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top