Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh a stale symlink linux

Is there a way to refresh a symlink once it has changed or gone stale?

I have a script which points to a link say:

/apps/myapps/release/current/....

Where current is a symlink pointing to say the latest release

Later I try to use a this link in a manner like

apps/myapps/release/current/scripts/start.sh

But if I have this current as working directory, changing the link won't change anything.

In order for this change to become effective, I would have to cd to apps/myapps/release and then back to scripts in order to access start.sh.

I am sure there must be a better way.

like image 638
Shawn Vader Avatar asked Dec 10 '22 02:12

Shawn Vader


1 Answers

Maybe

cd `pwd`

would be perfect. Let me have a look:

cd /tmp
mkdir a
mkdir b
touch a/OLD
touch b/NEW
ln -snf a cur
cd cur
ls # shows OLD
ln -snf b /tmp/cur
ls # shows OLD
cd `pwd`
ls # shows NEW
like image 118
glglgl Avatar answered Jan 01 '23 04:01

glglgl