I am looking to create a symlink for a file (E.g., /var/log/cron/cron.log
) which will have a symlink to both /proc/1/fd/2
and /proc/1/fd/1
.
Is this possible?
I am looking to create a symlink for a file (E.g., /var/log/cron/cron.log
) which will have a symlink to both /proc/1/fd/2
and /proc/1/fd/1
.
Is this possible?
No, it can only point to one target. Since a link points to a specific inode on the target, only one can exist at a time
Kevin already answered to the letter of the question, I'll try to answer to the spirit. If you want to write to two files at the same time (assuming one of the is not a hard/symbolic link to the other), you can use named pipes and the tee
command to duplicate output:
mkfifo dup.txt
tee -a a.txt >> b.txt < dup.txt &
echo "Hello world!" >> dup.txt
will get "Hello world!"
written to both a.txt
and b.txt
. However tee will exit after the first write.
Since in your example you use a logfile, a more stable solution would be to configure rsyslogd to send all cron
messages to multiple files:
cron.* -/var/log/cron/cron.log
cron.* -/var/log/another-file.log