abipc
abipc

Reputation: 1035

linux symlink - move logs from root to a mounted drive

My app uses log4j and writes the logs to directory A which is in root directory. I want to move the logs out to a mounted drive without making any change in the application.

Can I use soft symlink to do this? I have created a symlink like this -

ln -s A mounted_drive_directory

But I still see logs written to directory A.

Upvotes: 0

Views: 1441

Answers (2)

HardGlory
HardGlory

Reputation: 94

ln works a little bit different:

first argument is real folder\file, second - symlink.

mv /root/A /root/B; 
ln -s mounted_drive_directory /root/A; 

Upvotes: 1

keltar
keltar

Reputation: 18409

ln [OPTION]... [-T] TARGET LINK_NAME, so your arguments order is wrong. You'll have to delete (or move) A first before creating the link, or filename conflict will occur.

You could also use mountpoint bindings for that, e.g. mount --rbind /mounted/drive/directory /full/path/to/A, but it have to be done on each system boot (or saved in /etc/fstab to be auto-executed on boot).

Upvotes: 1

Related Questions