PIPES in syslog

Mezgani Ali
1 min readMay 25, 2019

Using syslog, there are a possibility to write the output to a pipe, so we can read this pipe from a program. But we have to be careful, syslogd should not wedge but we will have missing and/or mangled
messages if they arrive faster than our program can process them.

Let’s take look to how to create these pipes and read from them:

First create a named pipe using mkfifo:
mkfifo -p /home/mezgani/syslog.pipe

Make syslog.conf to points to this file:
*.info |/home/mezgani/syslog.pipe

Restart syslog:
sudo pkill -HUP syslogd

Create processing script that read the pipe
cat > foo
#!/bin/bash
cat /home/mezgani/syslog.pipe | while read input
do
# some stuff
echo ${input}
# ….
done

--

--

Mezgani Ali

Ph.D. student and researcher at (Native LABs, inc). I like technology, reading and my little daughter Ghita. My first program was an Horoscope in Basic in 1993.