0

I have to collect measurement files from different servers, so I used scp command to retrieve them. But in case the distant server is hanged or no response, I need to close the connection and put a 0 in my measurement file. Is there any option in scp command allow me to close the connection after 10 seconds for example?

for serv in $SERV_LIST
do
  echo "--- Working on server: $serv ---"
  trc_file=`ssh user@$serv "$(typeset -f collectSTATS); collectSTATS $serv $DATE $LastRunTime 
  scp user@$serv:/tmp/result_rechHM2_$serv.tmp /home/voms/HDB2/result_rechHM2_$serv.tmp > /dev/null 2>&1
  deleteFile=`ssh voms@$serv "rm /tmp/result_rechHM2_$serv.tmp 2> /dev/null"`
  if [ -f /home/voms/HDB2/result_rechHM2_* ]
  then
        cat /home/voms/HDB2/result_rechHM2_* >> /home/voms/HDB2/TraceRecharge.log
        rm -rf /home/voms/HDB2/result_rechHM2_*
  fi
done

When ssh or scp command fail with no response, I need to wait only 10 seconds.

Kenster
  • 23,465
  • 21
  • 80
  • 106

1 Answers1

0

we just use the ssh -o ConnectTimeout=5. it resolve my problem