Forum Moderators: phranque

Message Too Old, No Replies

Symbolic link

making 2 directories redirect to same one

         

Doood

9:28 pm on Nov 5, 2003 (gmt 0)

10+ Year Member



I've got the same script installed on 2 sites and they are both using the same db, but in order for it to work correctly I need the cache directory from each to use one common directory so if changes are made from one then the cache will be updated for both.

So here's what I need to do...Create a commoncache directory and delete both current cache directories (I was told to do this), then create a symbolic link from both script installations to the commoncache directory.

I was told to use this as an example


rm -r cache
ln -s /path/to/commoncache cache

But I'm not skilled at the command line and don't know if I'm supposed to be logged into ssh as the user and in a specific directory or something. I'm having a hard time figuring it out.

jdMorgan

10:35 pm on Nov 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Doood,

rm -r cache means remove (recursively) any file or directory named cache and all files or directories below it.

ln -s path-to-common-cache cache means create a symbolic link (effectively, a fake "file") named cache and point it to the real file at path-to-common-cache.

You'll need to do this for each cache you have now, in other words, twice.

So, create a directory anywhere called /common/cache and then create the symbolic links in the directories one level above where your individual cache files are now. In other words, substitute symbolic links for the individual cache directories, and point them to the common cache directory.

You might want to just rename the directories that hold your current cache files in case something goes wrong, but if they are true caches, then no harm is done by deleting them except to incur a temporary slow-down.

Remember to check the man pages for any command you're not clear on...

I'm not sure if you need to log in at anything but user level - I'm sure it'll be obvious pretty quick if you need higher priveleges!

Jim

Stretch

10:43 pm on Nov 5, 2003 (gmt 0)

10+ Year Member



Not my area of expertise but couldn't you use an Alias in the Apache config file to achieve the same result?

Doood

3:53 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



The biggest problem I'm having is probably the most trivial part of it. Using "remove -r cache" will remove the cache directory and everything in it, but I don't know if I'm supposed to just login to ssh for the user account in question and if so, if I'm supposed to be in the cache directory or one level above it and not in it when I type it in. Same with the "ln -s", I don't know where to run it from. I haven't figured out the command line stuff yet.

Also, you said to create the directory /common/cache, should it just be /commoncache instead?

When using "ln -s path-to-common-cache cache", I can't figure out what the full path is to commoncache, and if I need to also use the full path to the cache directory or not. All the help file I read tell me how to do the hard stuff, but automatically assume I already know the easy stuff like this, so I never get anything figured out.

I know it's not good to have someone explain everything in detail because I may never actually learn anything, but I just can't figure it out. I spent $40 on a linux book but it's not helping me so far.

jdMorgan

4:38 pm on Nov 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The biggest problem I'm having is probably the most trivial part of it. Using "remove -r cache" will remove the cache directory and everything in it, but I don't know if I'm supposed to just login to ssh for the user account in question and if so, if I'm supposed to be in the cache directory or one level above it and not in it when I type it in.

One level above it, since you'll be deleting the directory itself as well as the files in it.

Same with the "ln -s", I don't know where to run it from. I haven't figured out the command line stuff yet.

You can do that from anywhere, as long as you use a full path for both the link and its target. However, it's easier to go to the directory where you want to create the link: Then you can use a local path (filename only) for the link, and provide the full path for the target only - basically, it saves typos. Remember: think of a link as a file - it's just a fake file serving as an 'alias' or copy of the real one.

Also, you said to create the directory /common/cache, should it just be /commoncache instead?

Sorry, I meant "create a directory named something like /common/cache"... Didn't mean to be specific, and I have no special knowledge about your project - I haven't used your script.

When using "ln -s path-to-common-cache cache", I can't figure out what the full path is to commoncache, and if I need to also use the full path to the cache directory or not. All the help file I read tell me how to do the hard stuff, but automatically assume I already know the easy stuff like this, so I never get anything figured out.

I feel the same way about CSS! -- I keep doing things the hardest way possible, it seems. ;)
The path for common-cache is whatever you want it to be ... do a pwd command at any time to see where you are - that may help you get oriented. I'd suggest putting the cache between the highest level allowed and the lowest level that is still shared by the two scripts you want to share data. So, below the root directory, and above the 'user' level of directory.

Any questions I didn't answer - means I don't know. I'd rather leave them for someone else to help with than to give you a bad answer...

Jim