How do I disable messages or logging from printing on the console/terminals?

Latest response

Hi Team,

I have configured the syslog in RHEL7 but i'm getting logs on console and unable to run any commands .

Please suggest ?

Thanks

Responses

Hi Munusamy Kaveri,

Please let us know your '/etc/rsyslog.conf' file and any other additional configuration files being used. Also, tell us about the syslog version, kernel version, release and sample messages that you get console for further help.

You can restrict or disable console messages with the kernel.printk tunable.

Use it like:

echo 'kernel.printk = 2 4 1 7' >> /etc/sysctl.conf
sysctl -p

Further explanation of each of the numbers is given at: Machine slowdown or lockup, massive rate of logging seen on console

Thanks Jamie for sharing the KB. That should work.

Munusamy Kaveri, please let us know if that helped you.

Jamie,

I've seen the use of dmesg -n 1 - would that compare to the sysctl method at all? I think dmesg -n 1 is non-persistent though.

Regards,
RJ

A quick skim of the dmesg source in util-linux shows that it uses glibc wrapper klogctl() which allows control of the console kernel log level too.

That wrapper falls thru to the syslog() system call which allows control of the kernel's console_printk[] array, which is what the kernel.printk tunable controls too.

So yes, they are both interfaces to the same functionality. Nice!

I am not sure what kind of messages you get on your console but you can check if you have # in line with /dev/console in /etc/rsyslog.conf file. This in example below blocks (in my case) kernel outputs to console where i am logged in.

[root@RH77 ~]# cat /etc/rsyslog.conf | grep /dev/console

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console