From: Matt M. <ma...@ma...> - 2008-12-23 19:14:36
|
On Mon, 2008-12-22 at 18:26 -0800, Ido Magal wrote:\ > I just set up rsnapshot on my ubuntu box. I cobbled together the > following script to email the rsync log and the stderr once the backup > is complete. > > The problem I have is that the bash wait doesn't behave the way I > expect it given all I've googled. The script mails immediately and > then proceeds to rsync. I would appreciate any help in getting this > script to execute as designed. > #!/bin/sh > > LOGFILE=/mnt/drobo/home/rsync.$1.log > ERRFILE=/mnt/drobo/home/rsync.$1.err > CONFFILE=/mnt/drobo/home/rsnapshot.$1.conf > > [ -f $LOGFILE ] && rm $LOGFILE > [ -f $ERRFILE ] && rm $ERRFILE > > /usr/bin/rsnapshot -c $CONFFILE $2 2>$ERRFILE > wait > [ -f "$LOGFILE" ] %% cat $LOGFILE| mailx -s"[backup log: "$1"]" $1 > [ -f "$ERRFILE" ] %% cat $ERRFILE| mailx -s"[backup errors: "$1"]" $1 Your rsnapshot command is in the foreground (no &), so bash should be waiting even without a "wait" command. The % signs should be & as Kenyon said, but that doesn't explain the problem. There must be something else going on here. Try changing the shebang line at the top to "#!/bin/bash". Some people have gotten into a bad habit of writing "#!/bin/sh" for scripts that use bash-specific features, and Ubuntu (possibly among other distributions) is calling them on it. I know bash but have never taken the time to learn what features are part of the standard sh, so I just always write "#!/bin/bash". If that doesn't fix the problem, try adding "set -x" to see the commands as the shell is executing them. -- Matt |