The UNIX and Linux Forums  

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 -->
  #4 (permalink)  
Old 05-28-2009
droppedonjapan droppedonjapan is offline
Registered User
  
 

Join Date: May 2008
Posts: 8
Quote:
Originally Posted by in2nix4life View Post
If this is a Bash shell script you could try the 'wait' command.
For some reason the wait command doesn't work according to the documentation that you gave me. I've tried just doing this...


Code:

rsync -urza -e "ssh -i rsync-key -l username -p xxxx" /filepath/filename.zip webserv:/filepath/

wait

And it doesn't wait at all.

As for the lockfile, I'm not sure what that script does, exactly.


Code:
lockDir="/root/lock_files"
lockFilePath="$lockDir/file.lock"

while [ -e "$lockFilePath" ]
do

   exit
done

touch $lockFilePath

/usr/bin/rsync  --stats -e ssh -rlvtgoDz --delete  /dir/dir/dir/ root@server:/dir/dir/dir/ &

rm -f $lockFilePath

As far as I can tell, it starts out telling where the lock directory and file is. Then you say if the locked file exists, then if it does, then exit the script. Then if it isn't there, then you touch the file (thereby creating a blank file, if my "touch" knowledge is correct), and then starts the rsync in a background process. After it starts making the rsync, it then removes the lock file.

I could see this somewhat working if you made the script call itself before the while statement, but I don't know how this would improve my situation. Normally my script then removes the files that are being rsync'ed, so even if I called this script externally, the rm command would go through just as soon as this script finished, a la just as the rsync starts. And I really don't need to rsync multiple files, just one.

Any other ideas / suggestions?

(Thanks for what I have so far, by the way. )

EDIT: Also, I'm running all this on a Red Hat system. Forgot to include that earlier.