Copying large files in a bash script stops execution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying large files in a bash script stops execution
# 1  
Old 02-02-2014
Copying large files in a bash script stops execution

Hello,

I'm new to this forum and like to first of all say hello to everyone.
I've got a really annoying problem at the moment.
I'm trying to rsync some files (about 200MB with one file of 120MB) from a Raspberry PI with raspbian to a debian server via rsync.
This procedure is stored in a bash-script. I'm generating some output before and after the rsync-command to see and check if everything went fine.
Now, when copying large files, rsync completes the task, gives out information about what and in which size was copied, but the shell script stops. The following calls to functions are not executed.
If I test the script with many small files, it works well and the script executes all commands and quits as expected.
First I thought this is a problem with rsync, but copying (via cp) the same files to a smb-share stops exactly at the same point.

What I found out so far (some ideas come from my PHP-Experience):
1. Could it be related to some sort of timeout? Is there a timeout for a called function?
2. When I watch the output of rsync, I see that after a large file is copied rsync sort of hangs for several seconds before it transmits the next file. When using small files this "lag" does not show up.
3. Does it have something to do with the performance of the raspberry?
4. Either using rsync over ssh or not (simply copying to smb) has the same effect.
5. Also changing filenames (deleting whitespaces and special characters) had no effect.

Perhaps you have a clue?

Thank you very much

wex_storm
# 2  
Old 02-02-2014
Without seeing your shell script, it is difficult to give any useful advise on your issue. If you take the SMB share out of the picture and rsync or cp to a regular ext2/3/4 filesystem does your script work?
# 3  
Old 02-02-2014
Hi.

My guess -- there is some computing done at both ends of the rsync transaction. From: rsync - Wikipedia, the free encyclopedia:
Quote:
The recipient splits its copy of the file into fixed-size non-overlapping chunks and computes two checksums for each chunk ... It sends these checksums to the sender.

The sender then compares its rolling checksums with the set sent by the recipient to determine if any matches exist. If they do, it verifies the match by computing the hash for the matching block and by comparing it with the hash for that block sent by the recipient.

The sender then sends the recipient those parts of its file that did not match the recipient's blocks, along with information on where to merge these blocks into the recipient's version. This makes the copies identical.
So the longer the file, the more time it takes to do the checksums.

Best wishes ... cheers, drl
# 4  
Old 02-03-2014
Hi, first of all thank you for your answers.

Here is a shortened part of my script, where it "hangs" (after the rsync line, if big files are copied)
Code:
echo "Mounting SAMBA-Share..."
if [ "${SMB_OPTION}" = "" ];
then
    sudo mount -t cifs -o username="${SMB_USER}",password="${SMB_PASS}",rw,noserverino,nounix ${SMB_SHARE} ${SMB_MOUNT_POINT}
else
    sudo mount -t cifs -o ${SMB_OPTION} ${SMB_SHARE} ${SMB_MOUNT_POINT}
fi
echo "mounted"
gpio write 4 1
echo "Copying files to SAMBA"
mkdir ${SMB_MOUNT_POINT}${TIME_STAMP}
rsync -av --exclude="*/" --exclude=".*" --progress ${MOUNT_POINT}* ${SMB_MOUNT_POINT}${TIME_STAMP}
echo "Copying done"
echo "Unmounting SAMBA-Share..."
sudo umount -l ${SMB_MOUNT_POINT}
echo "unmounted"
gpio write 4 0

I just let the script run 20 minutes - it just does nothing after the lines:
sent 248566882 bytes received 829 bytes 2080064.53 bytes/sec
total size is 248533848 speedup is 1.00

Normally it echoes "Copying done" and so on. I'll just let it work for some time and let you know, if anything changed.

I tried copying the data to an internal folder (on the SD-Card) with absolutely the same result. Script hangs.

Appreciate your help.

wex_storm
Moderator's Comments:
Mod Comment Please use CODE tags (not ICODE tags) when tagging multi-line code, sample input, and sample output.


---------- Post updated 02-03-14 at 02:04 AM ---------- Previous update was 02-02-14 at 02:33 PM ----------

I forgot to mention that the script is started by an udev-rule.

Thanks

Last edited by wex_storm; 02-03-2014 at 03:54 AM.. Reason: Change ICODE tags to CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script search, improve performance with large files

Hello, For several of our scripts we are using awk to search patterns in files with data from other files. This works almost perfectly except that it takes ages to run on larger files. I am wondering if there is a way to speed up this process or have something else that is quicker with the... (15 Replies)
Discussion started by: SDohmen
15 Replies

2. Shell Programming and Scripting

Bash: copying lines with specific character to files with same name as copied line.

I am trying to make my script as simple as a possible but, I am not sure if the way I am approaching is necessarily the most efficient or effective it can be. What I am mainly trying to fix is a for loop to remove a string from the specified files and within this loop I am trying to copy the lines... (2 Replies)
Discussion started by: Allie_gastrator
2 Replies

3. Shell Programming and Scripting

Need help in finding and copying list of files using bash shell script

Dear All, I have a situation where I want to copy some files of type .txt. These files are o/p from one program. Some of the files are named as fileName .txt instead of fileName.txt after fileName by mistake I have specified "space". Now I want to move these files as follows. mv fileName*... (13 Replies)
Discussion started by: linuxUser_
13 Replies

4. Shell Programming and Scripting

Mount fails (because remote machine is off) bash script stops

Hi, I'm trying to automate a couple of mounts. (I would do this in fstab, but the auto feature causes the virtual machine I'm running in to freeze when it boots up) If the machine I'm trying to connect to is OFF, I get the host unreachable error and then the bash script stops. The problem is... (3 Replies)
Discussion started by: jdilts
3 Replies

5. Shell Programming and Scripting

Script stops working after copying it

Hi all, When I cp a script, this section of the code stops reading from a file. if ; then while read dirtoclean do DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean done < ${BASEDIR}test.conf fi ${DIRSTOCLEAN} doesn't return anything, even though it will work right before... (6 Replies)
Discussion started by: nicksantos1
6 Replies

6. Shell Programming and Scripting

Execution problems with BASH Shell Script

Hi I need help with my coding , first time I'm working with bash . What i must do is check if there is 3 .txt files if there is not 3 of them i must give an error code , if al three is there i must first arrange them in alphabetical order and then take the last word in al 3 of the .txt files... (1 Reply)
Discussion started by: linux newb
1 Replies

7. SCO

Need advice: Copying large CSV report files off SCO system

I have a SCO Unix server from 1999 running SCO 5.0.5 and some ancient accounting software called Real World A report writer program on the system is used to generate CSV files from accounting that we write with DOSCOPY commands to 3.5" floppies In the next 60 days we will be decommissioning... (11 Replies)
Discussion started by: magnetman
11 Replies

8. Shell Programming and Scripting

Execution Problems with bash script

Hello, can someone please help me to fix this script, I have a 2 files, one file has hostname information and second file has console information of the hosts in each line, I have written a script which actually reads each line in hostname file and should grep in the console file and paste the... (8 Replies)
Discussion started by: bobby320
8 Replies

9. Shell Programming and Scripting

Bash folder manipulation - selecting/copying specified files

Bash/scripting newbie here - I feel this might be a trivial problem, but I'm not sure how to tackle it. I've got a folder of a year's worth of files, with some random number of files generated every day of the year (but at least one per day). I'm writing a script to automatically grab the file with... (6 Replies)
Discussion started by: WildGooseChased
6 Replies

10. Shell Programming and Scripting

Copying of large files fail

Hi, I have a process which duplicates files for different environments. As the files arrive, my script (korn shell) makes copies of them (giving a unique name) and then renames the original file so that my process won't get triggered again. I don't like it either, but it's what we were told to... (4 Replies)
Discussion started by: GoldenEye4ever
4 Replies
Login or Register to Ask a Question