Solaris 11.4 dmesg

Hello

I have a question again.

I'm running Solaris 11.4.

Is there a way to clear the dmesg?

To clear the dmesg log on Solaris 11.4, you can use the dmesg -c command. This will clear the kernel's message buffer, which is where the dmesg log is stored.

Alternatively, you can use the echo > /dev/msglog command to clear the dmesg log. This works because the /dev/msglog file is used to interface with the kernel's message buffer.

Keep in mind that these commands will only clear the dmesg log for the current boot session. If you want to clear the dmesg log across reboots, you will need to edit the system's logrotate configuration to rotate the dmesg log more frequently or to disable rotation of the dmesg log altogether.

I hope this helps! Let me know if you have any other questions.

1 Like

I tried the two ways you told me, but it didn't work.

I'm sorry that the methods I suggested did not work for you. It's possible that there may be other factors at play that are preventing the dmesg log from being cleared.

Please copy and paste the commands you tried and all error messages or status messages.

Here are a few additional suggestions that you can try:

  1. Check the permissions on the /dev/msglog file. Only root or a user with the appropriate permissions should be able to write to this file.
  2. Try using the /usr/sbin/dmesg -c command instead of just dmesg -c. This will ensure that you are using the version of the dmesg command that is installed with the operating system, rather than any version that may have been installed by other software.
  3. Make sure that the dmesg log is not being rotated by logrotate. You can check the logrotate configuration by looking at the files in the /etc/logrotate.d directory. If you find a configuration file that is rotating the dmesg log, you can either modify the configuration to rotate the log less frequently or disable rotation altogether.
  4. Consider using the syslog command to clear the dmesg log. This command allows you to view and modify the system's syslog configuration, including the dmesg log. You can use the -c flag to clear the dmesg log. For example: syslog -c dmesg.

I hope one of these suggestions helps! Let me know if you have any other questions or if there is anything else I can do to assist you.

I think the given advice is for Linux only.
The Solaris dmesg simply reads the last 200 lines from /var/adm/syslog, and there is no -c option to clear it.
Solaris has logadm not logrotate. Of course you can rotate /var/adm/messages more often: you can use the logadm command to change its configuration, or directly edit the /etc/logadm.conf file.

Why do you want to clear the logs?
Diagnostics are there to help in case of a problem.

3 Likes

Yes, seems @chatgpt is confusing Linux with Solaris:

See:

Not a Solaris user, but the way I generally do this when I want to hit it with a hammer is to just truncate it in a crude way.

Assuming the file used by dmesg is:

/var/adm/messages

You can try:

cat /dev/null > /var/adm/messages

Not sure of the name of this file on Solaris.

OK. Just googled this.

According to the reference below:

So, you can simply clear this entire file by doing this. However, I recommend you copy it first in case you need it later.

Something like this ...

cp /var/adm/messages /var/adm/messages.backup
cat /dev/null > /var/adm/messages

Ref:

1 Like

Reminds me of the joke

Boss to secretary: "Please destroy these files, but make two backup copies first!"

2 Likes

thank you
your reply

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.