1

I work for a small software company. We have a product that by default writes to a logs directory inside the installation directory (I know, this may not be the best way, but it's fixed as of now): /opt/<program>/logs

I have a user that wants each of his users (on Linux) when running our program, to have logs written to their user directory per session, like /home/<user>/<program>/logs. Is there a good way to set this up, relying on my program always writing to /opt/<program>/logs by default?

I'm no Linux expert but I'm thinking this could be done.

Would this be better asked on the Linux SE board?

Any help is appreciated!

NOTE - These logs are created for the program when it runs, no matter who is logged in to use it. They all go to the same directory: /opt/<program>/logs. If I create a symlink, then all that does it duplicate the logs into another directory. What I need is each user's logs for their session into their respective /home/<user>/<program>/logs directory.

3 Answers 3

3

Create a link from the /opt/program/logs folder and point it to /home/user/logs:

ln -s /home/user/logs /opt/program/logs
1
  • See note above - not sure this get's me what I need. May 16, 2011 at 21:33
1

Try removing the /logs/ directory, and navigating to /opt/program and typing

ln -s ~/logs

However, you will need to add a

mkdir ~/logs

to each users startup script.

1

How does the log look like? Is there a possibility to check which user created an entry?
You could use the syslog-ng to watch for the files in /opt/<program>/logs and depending on the entry (e.g. a regular expression) writing a second logfile to $USERHOME/logs.

If just one user is using your program you may give him read-permissions to this directory and its files. But if there are sensible entries from other users this is a bad idea.

1
  • No way to see which user created the entry, as the logs are somewhat non-specific. Multiple users will be using this program, hence the need for separate logs... Thanks! I wonder if you could parse based on time, and connect that to the user login time... May 16, 2011 at 21:39

You must log in to answer this question.

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