If I decide I want to copy a folder that is sufficiently large using cp, then half way through the copy I decide to abort or pause the process, will this ever cause corruption? Would it be better to let the copy finish and then delete the files?
Asked
Active
Viewed 962 times
2
-
The files that are being created will be corrupt, but the file-system structure will not break. Just delete the files that were being created. – ctrl-alt-delor Jun 22 '18 at 22:17
1 Answers
3
If you pause the process and resume it later, nothing bad will happen. As long as nothing else writes to the input or output file in the middle, the output will be a faithful copy of the original.
If you kill the copy process, then you'll end up with a partial copy in the output file. There's no point in waiting: if you want to cancel the copy, cancel it as soon as you've decided and remove the partial output.
The input file will never be affected by the copy operation except that its last-read timestamp may be updated.

Gilles 'SO- stop being evil'
- 829,060
-
Thanks! Out of curiosity, why is the input file never affected by the copy operation? – nobody Jun 22 '18 at 20:40
-
1
-
1The input file may have its last access time-stamp update, unless atime is disabled. – ctrl-alt-delor Jun 22 '18 at 22:15
-
@ctrl-alt-delor If you want the full story: it will have its last-read timestamp updated, unless the partition is mounted read-only, the filesystem doesn't support atime, atime is disabled, or one of Linux's strange atime modes is enabled and this results in the atime not being updated. – Gilles 'SO- stop being evil' Jun 23 '18 at 11:32