Text file busy when I copy some files

28,649

Solution 1

try

rm -f /applis/rgedff/pur/bin/lib/libtiny.old
mv /applis/rgedff/pur/bin/lib/libtiny.a  applis/rgedff/pur/bin/lib/libtiny.old

before copying, be aware that you may disrupt any program that use /applis/rgedff/pur/bin/lib/libtiny.a

libtiny.a is a share library, active running program are using it, and you can't delete file being used in Linux.

More precisely, deleting such file will result in removing filename from directory, while file data will be kept in filesystem as long as a running process use them.

Solution 2

I have seen this happen to me when I was copying files from one hard drive to another through a connection such as NFS or an SSH tunnel.

What happens is that the file being copied becomes part of the destination directory. That means the destination directory needs to be locked, updated with the new information, and then unlocked.

If the next file (which in your case would be libtiny.a) arrives too soon, it tries to lock the directory and fails with the "File busy" error. That then prevents the copy of that file and anything further.

Since libtiny.a is a static library, there are no reasons why it would ever be locked against a copy. As far as I know, the compiler does not lock the files it is working on, and really it would only happen if you were compiling something in the target directories...

Now this is assuming that all the disks use a normal file system. If you used NTFS, then files cannot be replaced while opened because that system does not allow for such to happen.

Under Linux, opening a file locks that file's data in place, but it does not prevent you from unlinking it, renaming it, replacing it. If the file was deleted, the locked data will be released from the hard drive once all the handles to that file get closed.

This means you can write a program which, when it gets executed, deletes itself from the hard drive and yet it will continue to function as if nothing had happened.

Share:
28,649

Related videos on Youtube

Mercer
Author by

Mercer

Updated on September 18, 2022

Comments

  • Mercer
    Mercer over 1 year

    I have this error when I want to copy some files

    My command:

    cp -rf  /sasech/xgedff/pur/liv/v15h30050-DLIV0177521/dmesa/bin/* /applis/rgedff/pur/bin
    

    Results:

    cp: /applis/rgedff/pur/bin/../bin/lib/libtiny.a: Text file busy
    ...
    

    How do I copy my files ?

  • Арсений Черенков
    Арсений Черенков over 8 years
    @mercer path above to be replace by your actual paths.
  • schily
    schily over 8 years
    Because your proposal is risky, I recommend to use star -copy -p -install.
  • Alexis Wilke
    Alexis Wilke over 7 years
    libtiny.a is a static library, it would be a problem to overwrite it only if there is a compiler currently linking and having that file opened and locked.
  • user60561
    user60561 over 6 years
    I received this same error while trying to do a build inside a virtual machine, with the build directory shared (mounted as a vboxsf filesystem) from the host Windows PC. The solution was to do the build on the virtual machine's disk. I had no problems after that.
  • Alexis Wilke
    Alexis Wilke over 6 years
    @user60561 Yes, if the host is MS-Windows, then you are using NTFS and that uses hard locks.