LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   scp truncate text file busy - copying file is not a running binary (http://www.linuxquestions.org/questions/linux-server-73/scp-truncate-text-file-busy-copying-file-is-not-a-running-binary-814106/)

jetberrocal 06-14-2010 01:59 PM

scp truncate text file busy - copying file is not a running binary
 
1 Attachment(s)
I am having problems with scp during a backup operation

I added a ps -ef before and after the scp operation used during the backup.

The backup is a script to backup a Zimbra Server

I am including the code segment that I am having problems

Code:

        # DRCP Section. To scp newly created archives to a remote system
        if [ "$DRCP" = "yes" ]
        then
          echo ""
            ps -ef
          echo ""
            CPNAME=`ls -A "$ARCHIVENAME"*`
            SCPRC=0
            echo "copy archive to $REMOTEHOST" remote directory $REMOTEDIR
            if [ "$SSHKEY" = "rsa" ]
            then
                  scp -i /root/.ssh/id_rsa $CPNAME "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
                  SCPRC=$?
            elif [ "$SSHKEY" = "dsa" ]
            then
                  scp -i /root/.ssh/id_dsa $CPNAME "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
                  SCPRC=$?
            elif [ "$SSHKEY" = "rsa1" ]
            then
                  scp -i /root/.ssh/identity $CPNAME "$SSHUSER"@"$REMOTEHOST":"$REMOTEDIR"
                  SCPRC=$?
            fi
            echo ""
            ps -ef
          echo ""
          if [ "$SCPRC" -ne "0" ]
              then
                    echo "Error copying archive and checksum to $REMOTEHOST"
                    mail_log
                    exit 1
              elif [ $TYPE = "full" ]
              then
                    echo "$ARCHIVENAME"
                    echo "ssh $SSHUSER@$REMOTEHOST" "rm -f $REMOTEDIR/$LAST_FULL_WEEK_$BACKUPNAME*"
                    ssh "$SSHUSER"@"$REMOTEHOST" rm -f "$REMOTEDIR"/"$LAST_FULL_WEEK"_"$BACKUPNAME"*
            fi   
        fi

I am including the log that is sent during the backup by email as attachment since is too long

How can I see which process is locking the file that is being truncated?

rweaver 06-14-2010 02:29 PM

Try lsof it shows open files.

jetberrocal 06-14-2010 03:25 PM

I will replace ps -ef
 
Quote:

Originally Posted by rweaver (Post 4003427)
Try lsof it shows open files.

Thank you for your promptly response.

I will replace the ps -ef line with lsof in the code.

This script backup runs only on Saturdays, and do not have a test system that could replicate the problem sooner.
I will make the change on the code today, but I have to wait until Monday to see the outcome.

So I will have to post again in this thread next week. Sorry for the delay.

jetberrocal 06-24-2010 03:56 PM

I change ps -ef by lsof and this is what I got
 
1 Attachment(s)
After changing the ps -ef line to lsof I did not see why the scp reports Text File busy.

I am including the new email outcome as attachment

The attachments do not accept file larger that 256KB, but the email is 1MB large so I zipped the file.

Zip is not a permitted extension so I appended a .txt to the file name

I think the problem is some kind of timeout of the scp command.

It copies successfully various files, among them two of 4GB size, before failing with this file which is a 2~3GB file


All times are GMT -5. The time now is 06:30 AM.