I am writing a ksh script that allows multiple users to access a
resource and I was wondering if the mv command can be considered
atomic. If two users run my script at exactly the same time, can I
safely assume that the one that does the first mv request will get the
file? I was thinking and if I am not mistaken, the way mv works is to
1. Create a link to the file,
2. delete the old link to the file.
If two copies of mv are running simultaneously,
1. The first copy will create his new link to the file,
2. The second will create his new link to the file
3. The first copy will delete the old link to the file
4. The second copy will try to delete the old link that is not there
I guess that mv will return a non-zero return code if it goes to
delete a link that is not there but this scenario will still result in
two links to the same file.