Home  >  Q&A  >  body text

Will Linux report an error when using mv to move files that are being read and written?

1) What will happen if you use the mv command to remove the file being read in the Linux system?
For example, file 1.txt is being read by process A. If I use the mv command to move 1.txt to another directory, will process A make an error?

2) What will happen if mv removes the file being written?
For example, file 2.txt is being written to data by process B. If you use the mv command to move 2.txt to another directory, will process B make an error?

There are two situations for mv to move files to other directories:
1) Move to a different directory in the same partition
2) Move to a different directory in a different partition

Will there be different results for mv movement in the above two situations?

Please give me some advice.

世界只因有你世界只因有你2710 days ago1813

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-18 10:53:33

    While I was eating, my job was robbed. Can anything happen?

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-18 10:53:33

    There is no problem with the same partition. Linux uses inode. As long as there is another process using the file, you can continue to read and write if you delete the file. Sometimes accidentally deleted files are saved based on this principle.
    Different partitions will cause different inodes, and strange phenomena will occur.

    reply
    0
  • Cancelreply