I am using a named pipe to trap syslog messages. I can then easily view syslog by doing something like
cat /var/log/local3.pipe | grep somefilter
or
grep somefilter /var/log/local3.pipe
These both output the syslogs to the console very nicely. However, if I then want to capture that to a file I get nothing, eg
cat /var/log/local3.pipe | grep somefilter >> somefile.log
or
grep somefilter /var/log/local3.pipe >> somefile.log
The file always remains as zero bytes. Does anyone know why? I'm using Red Hat Enterprise Linux 5. Thanks.
Additional info: For anyone who wants to reproduce this here's the full list of commands
su
<enter root password>
mkfifo /var/log/local3.pipe
chmod 644 /var/log/local3.pipe
echo "local3.* |/var/log/local3.pipe" >> /etc/syslog.conf
/etc/init.d/syslog restart
exit
then with one ssh session:
cat /var/log/local3.pipe
and in a second ssh session ("Test it" should show in first ssh session
logger -p local3.info "Test it"
then in the first session change it to
cat /var/log/local3.pipe >> somefile.log
send some more logs to local 3 (message needs to be different). Confirm that messages are going into somefile.log
logger -p local3.info "Test it 2"
then in the first session change it to
cat /var/log/local3.pipe | grep -i test >> somefile.log
now confirm that logs are not going to somefile.log
Note that the message needs to be different from the last message otherwise the logger doesn't send it immediately.