![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pause() problems | IdleProc | UNIX for Dummies Questions & Answers | 1 | 03-17-2009 06:21 PM |
| Pause for response from the log file | gxdanh | Shell Programming and Scripting | 3 | 10-24-2008 12:52 PM |
| Rsync script in cron from stepping on itself | sunsysadm2003 | Shell Programming and Scripting | 3 | 04-30-2008 12:14 PM |
| pause? where art thou? | 01000101 | High Level Programming | 3 | 05-15-2006 08:42 PM |
| how to pause another process? | daneensign | UNIX for Dummies Questions & Answers | 1 | 02-14-2006 12:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Script Pause Until Rsync Is Done Transferring
Alright, I have this script that pulls files from a few locations, process those files, creates a zip file, rsync's it and then removes everything.
The problem that I'm having is that I do not know how large the rsync'ed zip file is going to be. Right now I'm using a sleep command before I remove all the files and directories created, however I'm uncomfortable in leaving it like this. All it would take would be a large file that it needs to rsync and the script would delete the file before it's done being transferred. So, is there a way of having the script check the progress of rsync? If not, how would I go about doing something along these lines? |
|
|||||
|
If this is a Bash shell script you could try the 'wait' command.
See more here - Job Control Commands Hope this helps. |
|
||||
|
Quote:
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. |
|
||||
|
If I understand this correctly, you're looking for a way to make sure that the rsync completes successfully before moving on to the rest of your script. bash would allow you to do this with the '&&' operator (in this case rsync is command1 ): Code:
command1 && command2 From the bash man page, "command2 is executed if, and only if, command1 returns an exit status of zero." So, something you might be able to use would be : Code:
rsync -options file.xx remotehost:/path/to/store && rm file.xx The gotcha here is that rsync can fail for a couple different reasons and if it does, the second command would not execute. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|