Article 5458W have cp copy to temp file then mv

have cp copy to temp file then mv

by
Skaperen
from LinuxQuestions.org on (#5458W)
the cp command copys normally by opening the target file directly, truncating it as it opens, then copying. this has strange effects when copying to a file another process is currently reading. what i have to avoid that is a script to copy to a temporary file first, then move the temporary into place.

i would like to know if there is an option to get cp to do that.

i do not want to remove it first (--remove-destination) as some process may try to open it at that instant. it should try to open the destination file with O_EXCL and if it gets EEXIST then do the temporary thing. my script can't do it quite right, although maybe it is better to not have a new file to initially exist empty.latest?d=yIl2AUoC8zA latest?i=OcpJa3qLNdg:nbvrWmVbI3Q:F7zBnMy latest?i=OcpJa3qLNdg:nbvrWmVbI3Q:V_sGLiP latest?d=qj6IDK7rITs latest?i=OcpJa3qLNdg:nbvrWmVbI3Q:gIN9vFwOcpJa3qLNdg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments