keep symbolic links up to date / update symbolic links

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

keep symbolic links up to date / update symbolic links

Postby Lakatusch on Tue Nov 10, 2009 5:34 pm

Hi all,

i have a lot of symbolic links in one folder.

If i copy a new folder into an existing folder, a new symbolic link isn't created automatically.

At this time, i use the following script, to keep the links up2date:

Code: Select all
rm -rf /home/xxx/movie/*

ln -sf /home/xxx/hdd1/* /home/xxx/movie

ln -sf /home/xxx/hdd2/* /home/xxx/movie

ln -sf /home/xxx/hdd3/* /home/xxx/movie


Is it possible to update the links automatically, when i rename or add oder delete a folder in/into /home/xxx/hddx/ ???

Thanks a lot.
regards
Daniel
Lakatusch
Level 1
Level 1
 
Posts: 10
Joined: Tue Nov 10, 2009 7:37 am

Linux Mint is funded by ads and donations.
 

Re: keep symbolic links up to date / update symbolic links

Postby Husse on Sat Nov 21, 2009 10:47 am

To update completely automagically you would need something to catch the event, but that's a bit tricky but not impossible I think
However it's outside the scope of normal support (and I don't quite know how either)
However your script seems to do more than update links
If I don't completely misunderstand rm -rf /home/xxx/movie/* would delete the content of /home/xxx/movie/*
And I'm a bit confused by all the * ... should not be necessary?
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: keep symbolic links up to date / update symbolic links

Postby Lakatusch on Sat Nov 21, 2009 10:58 am

Hi!
Yes, the /* is necesarry, otherwise you have only three folders under movie.
Meaning, you have hdd1, hdd2 and hdd3 under movie, but not the content of these three shares.
regards
Daniel
Lakatusch
Level 1
Level 1
 
Posts: 10
Joined: Tue Nov 10, 2009 7:37 am

Re: keep symbolic links up to date / update symbolic links

Postby Husse on Sat Nov 21, 2009 11:33 am

Sometimes I read without really seeing - why on earth not just mount the drives in /home/xxx/movie?
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: keep symbolic links up to date / update symbolic links

Postby Lakatusch on Sat Nov 21, 2009 12:24 pm

hdd1, hdd2 and hdd3 are phyical drives.
If i copy a file i want to decide on which physical drive this file should be stored.
If i mount all drives in one folder I'm not longer able to decide.
regards
Daniel
Lakatusch
Level 1
Level 1
 
Posts: 10
Joined: Tue Nov 10, 2009 7:37 am

Re: keep symbolic links up to date / update symbolic links

Postby Husse on Sat Nov 21, 2009 12:52 pm

Is the folder called xxx - I thought that stood for a real name so that there are three folders
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: keep symbolic links up to date / update symbolic links

Postby emorrp1 on Sat Nov 21, 2009 1:13 pm

hdd1, hdd2 and hdd3 are three separate partitions on the same physical disk drive (hdd). Either you want the contents separate, in which case why do you want them directly under movies? Or you want the contents together (under movies) in which case why don't you just have a single partition? Now I could understand if you actually had 3 separate HDDs because your movies are too big for just the one, which I thought was the case, in which case I was going to suggest you look into Logical Volume Management (LVM) which lets you treat multiple HDDs as if there was one big partition. Perhaps if you describe your situation more fully - what you have and what you want to do - then we could help you out.

Now if you're really set on this method, there are multiple ways to do it. Probably the easiest is to periodically run that script, so there's only a short delay until the symlink is created (though I'd use the more safe "unlink" command rather than "rm") - to do this type "crontab -e" and type in the following line:
Code: Select all
*/30 * * * * /home/xxx/movie_script

where /home/xxx/movie_script is the *full* path to your script and 30 is the length of time in minutes between running the script (smaller will make it appear faster, but will also take up more system resources and potentially make it more difficult to actually access the files (since you're removing the symlinks before re-instating them). Alternatively you could look into programming with inotify.
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com
emorrp1
Level 8
Level 8
 
Posts: 2322
Joined: Thu Feb 26, 2009 8:58 pm

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], expat_tony, Google [Bot], Google Adsense [Bot], Google Feedfetcher and 39 guests