3 ms·
To change a symlink I use: ln -snf NEW_SOURCE TARGET
by bshep 17y ago
To change a symlink I use:
ln -snf NEW_SOURCE TARGET
- ajross 17y agoWhich works fine, but is still not atomic. To be clear, saying something is "atomic" means that there is no way for another process to see the process in an intermediate state (in the example in the article: a missing or incorrect symlink to a deployed web application). Underneath the hood, the /bin/ln program still needs to call unlink() on the path first, so there is a short period of time during which the desired link isn't present. So software written to assume that the link is always valid (for example, because its author was told that the update was atomic) will have hidden bugs. This kind of tool merely runs really fast. The race condition is still there.
- bshep 17y agoI never said it was atomic ;-) just that i use that method rather than mv. I mainly use it when i'm updating apps or SDks to newer versions and want to keep the old ones around just in case.