I'm using a shell script below for doing some rsync on a remote host. By ssh to jumphost and from there ssh again and initiating the rsync as below.
Here I need to capture the log start and end date. But somehow when i executed below script, as it prints both log at the same time.
To be more precise, here the script spawns on ServerA , then jumping to ServerB, again it jumps to ServerC and then it hit the rsync command. Here I need to capture the start time and end time of rsync command on ServerA. But this end time which is not working as expected, once the script starts it keeps record the start and end time on logs.txt, but i can see the rsync process is still progressing.
date="`date +%T-%D`" i=folder echo "Log started at $date for $i" >> logs.txt ssh -T -i key user1@HOST1 "ssh -T user2@HOST2 << EOF rsync -av --progress source dest EOF" ###Here the logging not excecuting after the rsync command. if [ $? -eq 0 ]; then echo "Log ended at $date for $i" >> logs.txt fi
Here i would need this script to be active once the rsync process to finish on the remote host and then it proceed to the log ended part.
I already tried the wait command, but this also not helped
Any ideas appreciated