This does sound a good solution on paper, but "checking at the start" and "creating a file" are two different steps (i.e. not atomic) and will cause trouble eventually if your system has the tendency to run the script twice. A better solution is to use the `flock` command before creating the flag file. For example,
flock -n 999 || exit 1
if [ ! -f flag_file ]; then
echo "script not ran before, running"
echo " already ran, exiting"
# do stuff here
The first safely creates a temporary file. The second (with noclobber set or -n argument) will atomically rename a file, but not overwrite existing contents.
Linux uses symlinks to system library files in order to allow in-place atomic replavement without affecting running processes with open filehandles to earlier versions. MS Window's lack of this feature is what makes (or made, I'm very out of date) malware removal and system updates so painful.
Nope. If you rm a library, the processes using that library keep using the old library. Symlinks have nothing to do with it.