[英]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. 我的应用程序使用log4j并将日志写入根目录中的目录A。 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. 但是我仍然看到日志写入目录A。
ln [OPTION]... [-T] TARGET LINK_NAME
, so your arguments order is wrong. ln [OPTION]... [-T] TARGET LINK_NAME
,因此您的参数顺序错误。 You'll have to delete (or move) A
first before creating the link, or filename conflict will occur. 您必须先删除(或移动) A
一个链接,然后再创建链接,否则会发生文件名冲突。
You could also use mountpoint bindings for that, eg 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). 您也可以为此使用mountpoint绑定,例如mount --rbind /mounted/drive/directory /full/path/to/A
,但是必须在每次系统引导时完成(或保存在/etc/fstab
中才能自动-在启动时执行)。
ln
works a little bit different: ln
工作方式略有不同:
first argument is real folder\\file, second - symlink. 第一个参数是真实文件夹\\文件,第二个是符号链接。
mv /root/A /root/B;
ln -s mounted_drive_directory /root/A;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.