Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

Atomically replace symlink with the folder it points to

$
0
0

I have a symlink that points to a directory mounted via network file system like so:

2023 -> /mnt/bulk013/obs_data_archive/metwatch/2023/

now I want to replace the symlink with the folder that it points to in a fashion that doesn't disturb a productive application that frequently reads from this directory (atomically). This meant in my case first copying all the data to my local harddrive (where the folder 2023 lives). I did so and used a temporary directory to store the files:

2023.tmp/

So now the question is, how can I atomically switch the symlink with the actual folder, so that the folder then has the name 2023?

2023 -> /mnt/bulk013/obs_data_archive/metwatch/2023/   # remove this2023.tmp/  # and replaced with this (renamed to 2023)

Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>