The correct answer to the wrong question
If you need a fast, atomic move, then mv is what you need to do, since man 2 rename
says:
If a new path already exists, it will be replaced by an atom (subject to several conditions, see ERRORS below), so it makes no sense that another process trying to access the new path does not detect it.
Perhaps, more importantly, mv is basically a directory entry operation, which is why it is very fast compared to copying a file in any normal circumstances.
The right answer to the right question
If you are concerned about power outages or unexpected system outages, follow these steps:
- Attach an uninterruptible power supply. Indeed. Decide for a threat model.
- Make sure you are using a battery-powered RAID controller.
- Make critical recording synchronous.
- Use a journaling file system that stores log data, not just metadata.
The mv command should be faster, but reliability in the face of catastrophic failures is a hardware or file system problem.
source share