we have an application where one environment variable can hold only 1
value like below:
LOGDIR=/some/path
Now we have a requirement that we want to direct this file generation
to two directories at the same time . I've talked with application
developers but it seem that only 1 path is possible to achieve.
Can someone please guide how we can use multiple paths so that once a
file is copied in the above folder , it actually moves into two
directories. I've tried using soft-link but it looks I need a reverse
of soft-link
drwxr-xr-x 2 root root 4096 Sep 11 13:13 bss
lrwxrwxrwx 1 root root 3 Dec 10 18:39 newbss -> bss
lrwxrwxrwx 1 root root 3 Dec 10 18:39 anewbss -> bss
What I'm lookinig for is that I want to have two destinations for a
single link file like below:
drwxr-xr-x 2 root root 4096 Sep 11 13:13 baass
lrwxrwxrwx 1 root root 3 Dec 10 18:39 bss -> newbaass
lrwxrwxrwx 1 root root 3 Dec 10 18:39 bss -> anewbaass
Can someone help on this please?
Regards,
/BB/
You want one output stream to write two files at the same time? I don't
believe what you want is possible... on Solaris, or any other OS that I'm
familiar with.
You'll have to look at a different solution... like a second process, that
monitors the output on the "main" file and duplicates it to the second file.
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
RAID-1 might be a possible solution here! The file would be written to
two different physical disk drives.
But I think it's time to ask "What problem are you/they trying to solve?"
On my Solaris 10 11/06 box, I can use a named pipe with success. I
would assume any other box that has the ability to create a FIFO file
would would as well.
1. Create named pipe
$ /usr/bin/mkfifo /tmp/bss
2. List /tmp/bss
$ ls -la /tmp/bss
prw-r--r-- 1 user group 0 Dec 10 16:45 /tmp/bss
3. In terminal 1, feed date data into the named pipe
$ while :; do echo `date` >/tmp/bss; sleep 5; done
4.In terminal 2, write two logs from the single named pipe
$ while :; do cat /tmp/bss | while read LINE; do echo $LINE > /tmp/
newbaass; echo $LINE > /tmp/anewbaass; sleep 1;done; done
5. In terminal 3, confirm both logs have same date/data
$ cat /tmp/newbaass /tmp/anewbaass
Thu Dec 10 16:50:27 EST 2009
Thu Dec 10 16:50:27 EST 2009
I know, its a hack... but it works for me, your mileage may vary.
Hope that at the very least points this points you in the right
direction.
Thanks,
Juan
Never heard of 'tee'?
echo Line | tee file1 > file2
In any event, instead of reading a named pipe as if it was a file and
writing two files, I think his life would be easier if he simply wrote
one file in the first place and read/copied it to a second file. Using
a named pipe introduces all kinds of complexities which could result in
data loss. If he at least writes one solid file he has something to refer
back to.
Better yet, if he wrote to the first file and then hard linked the
second "file" to the first one. That will usually be faster and less
prone to problems. However, if he expects to modify one of the two
instances of the file without affecting the other, a hard link would
not work well.
-Greg
--
Do NOT reply via e-mail.
Reply in the newsgroup.
> In article
> <97f844e2-c945-4c1e...@k4g2000yqb.googlegroups.com>,
> Yep, go back the drawing board and tell the developers to rethink this
> requirement. It's not possible at the time of file creation. You can
> write utilities that kick off periodically (hourly or a fraction
> thereof) to ensure the directories are in sync, but not at the time of
> writing.
Isn't this the sort of problem that "tee" addresses? It works on pipes and
standard out and such. You might be able to hack something if your output
can be forced into going to a pipe.
Yes, I have heard of "tee", thanks for asking.
Try the "ln" command. Putting a file "into a directory" is rather
misleading terminology! A directory is nothing more than a file that
contains pointers to other files. Ten or a hundred directories could
point to the same file.
My post came out snarkier than I intended. Sorry about that.
OK, so this is an in-house application. The requirement here, would
suggest (STRONGLY!) to me that the developers remove the limitation you
mention in the first paragraph. Fix the application to either parse a
multi-valued string, or (even better!) just use syslogd.
While it's possible to work around, this really isn't a problem that
should be solved at the OS level.
Colin
Maybe this is not what you ask for, but can't you do it with filesync?
Just as an example:
mkdir {,a}newbaass
touch newbaass/1
filesync -o src -s ~/newbaass -d ~/anewbaass '*'
echo anewbaass/*
anewbaass/1
Now they are synced and a ~/.packingrules is created, so
filesync -q can be run in a loop+sleep or cron and hold the 2 dirs
in sync both ways even if you skip the -o src
But in this case, rm of files will also be synced, not sure you like that.
If you will have an online spare copy, use a revision control system instead,
/bb
I don't think the OP ever made clear just what it was he wanted. He
could be talking about two copies of the same data in two different
files OR he could be talking about ONE copy and multiple links from
different directories. The first interpretation creates a problem with
keeping the data in the two files identical.
I asked him several days ago "What problem are you trying to solve?" I
don't recall that there was any response.
I'm sorry I couldn't get online these days with groups.
yes, what I m interested in is that I want to write a file which would
actually redirect the input into two different files...
named piping or even commands can't be a reason here because the
writing process did never know about the destination as a programe.
the only way I can think is that a filesystem utility like double-link
( instead of single one-2-one link ), which would write the data in
two different file.
sorry again.
Regards.
I don't recall ever encountering a file system that would do that! RAID
1 will do this at the disk level.
I reiterate!
WHAT PROBLEM ARE YOU TRYING TO SOLVE?
--
draco vulgaris