Am So, den 26.03.2006 schrieb Fajar Priyanto um 8:16: > I want to do an rsync of my qmailtoaster directory > (/home/vpopmail, /var/qmail, etc) from another machine. > > Since this involves several directory, can anyone help me how to make the bash > script so that the second rsync command will wait util the first rsync > command finishes? I think we can use sleep command, but I'm sure there is > more appropriate ways (such as using exit code?) That is the default case: each command is executed after the other. What you could try is using: command1 && command2 && command3 ... This means the following command is only executed if the other finished successfully. But that is probably not what you want regarding the error handling. An alternate could be to write a little script which makes use of temporary PID files. Let each rsync command create such a PID file and let the following rsync command only start if the PID file of the former rsync got erased by the terminated command. An advanced example can be found on http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/communications.html under "rsync". > I imagine the script will be like this (pls mind the word wrap): > #!/bin/bash > rsync -avzgorp --delete -e ssh root@xxxxxxxxxxxxx:/var/qmail/ /var/qmail/ Hm, why all these options? You are using "-a", so it already sets "rlptgoD". Your options combination could just be "-avzD". ("-D": are there really devices in what you rsync?). > Fajar Priyanto | Reg'd Linux User #327841 | Linux tutorial Alexander -- Alexander Dalloz | Enger, Germany | GPG http://pgp.mit.edu 0xB366A773 legal statement: http://www.uni-x.org/legal.html Fedora Core 2 GNU/Linux on Athlon with kernel 2.6.11-1.35_FC2smp Serendipity 17:00:05 up 12 days, 17:47, load average: 0.53, 0.26, 0.14
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil