1

I'm wondering if anyone knows of a nice way to partially duplicate (hard link) files between two directory structures?

My current fall back is a script invoked by cron.

As background:

I ask since I have two groups who both need to access a body of files in a directory structure served via HTTP using Tomcat. A privileged group may access all the files and a less privileged group may only access a "public" subset. These sets are not aligned to particular directories but the different class of file can be identified by their naming convention (but not extension).

Therefore my current idea is to serve two separate directories, one containing only private (possibly password protected) and the other containing public. Then to run some periodic process whereby I create hardlinks from the public files so they appear in the private directories for the convienence of the privileged users. I choose to link in that direction since it's more important that the file is available immediately for the unprivileged users. (priv = admin, unpriv = regular user)

I hope that makes sense. I'll try to clarify if anyone has any questions.

2 Answers 2

1

I would use symbolic links.

You could use this Bash script:

#!/bin/bash
ln -s $1 $2/$(basename $1)

with something like these two commands:

find unpriv_criteria -exec ./linkscript {} /unpriv/dir \; 
find priv_criteria -exec ./linkscript {} /priv/dir \;
3
  • Why do you recommend soft links? I was prefering hardlinks since I won't have to configure Tomcat to follow soft links. In addition it would afford me the luxury of being able to remove files from the public directory without removing it from the private directory. Hope that makes sense? Jan 14, 2010 at 6:43
  • Here is a discussion of hard and symbolic links: serverfault.com/questions/10543/… Jan 14, 2010 at 9:18
  • Thanks for the link. I know the difference and the pros/cons but was wondering why you explicitly recommended using soft links. Jan 14, 2010 at 9:27
0

Something like what Dennis proposed would work in a cron job or similar.

If this were linux, I would point you at inotify which would allow you to eliminate the cron job and latency from hardlinks reflecting the original directory.

This doesn't appear to exist under Solaris, however.

If the hardlinks are not too critical, a cron job will probably do just fine.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .