Sending Errors to A Specific Console?

Henry Yen blinux-mail at
Tue Nov 1 08:48:54 UTC 2011

Two concepts are needed for the best solution for this.  First, the concept
of the naming of the Linux virtual consoles.  You already know that
consoles are "/dev/ttyN" (so console "tty22" is device "/dev/tty22").
"/dev/tty" and "/dev/tty0" are usually synonyms for "whatever console
is currently selected at the primary display".  Some time ago, Linux
also added a "/dev/console", which typically has the same effect as the
above two, but is now treated as a separate device.  Yes, that's confusing,
but the documentation file (/usr/src/linux/Documentation/devices.txt) wants
to make this clear distinction.

The second concept is that of syslog (the syslog daemon).  Depending on which
syslog you are using (usually "syslog-ng", but sometimes just "syslog"),
you can configure exactly how various log messages are handled.  A regular
program or daemon can emit a message to the "syslog", and the Linux kernel
itself, of course, also emits messages.  Note that the verbosity of kernel
messages can be separately specified as the "kernel log level".  Anyhow,
the syslog/syslog-ng configuration file specifies what you want to do with
each message that the "syslog" service receives, with options such as writing
the message to a file (e.g. "/var/log/messages"), piping the message to a
new program invocation, and/or writing the message to a "/dev/ttyN" console
(or perhaps "/dev/tty0" or "/dev/console").

If you are already getting messages on the "console", figure out which
syslog daemon you're running and look for "console" or "tty" in its
corresponding config file (e.g. "/etc/syslog-ng/syslog-ng.conf" or
"/etc/syslog.conf").  This scheme allows a tremendous amount of flexibility
and will allow you to process these messages in just about any way you
might want.  There are "man" pages available for klog and syslog.

Oh, an additional wrinkle.  The "klogconsole" command is used to control
(I believe) an additional copy of kernel messages that are directed to
a specified console/tty.

On Sun, Oct 30, 2011 at 17:18:09PM -0700, Hart Larry wrote:
> Hi All:  This is first of 2 complicated questions?  The other evening I had 
> a hard-drive failure--and 9 lines of errors were blasting out, but even 
> worse each time I would change consoles, the same errors showed up again.  
> So my idea would be if first I could select a console such as tty22  where 
> all error messages would go.  Then for those who figure its important to 
> know of and examine them, maybe the PC speaker could ring 2 rapid bells.  
> At least that wouldn't messup my screen while I am reading in Pine.  When 
> looking up this concept, it seemed like a program "klogd" might do this, 
> but in asking at our LUG last evening, maybe not.
> Even when I plugin or disconnect a USB device, the message comes on my 
> current console.

Henry Yen                                       Aegis Information Systems, Inc.
Senior Systems Programmer                       Hicksville, New York

More information about the Blinux-list mailing list