Page 1 of 1

delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 11:29 am
by jatindeepsharma
Hello Team,
Good Morning. I want to delete mysqld.logs from NAGIOS SQL server cause their size is huge , its about 20GB. i have seen these logs & they include error messages of database table crashed in it.
Is it safe to delete these logs, if yes then how can i delete these logs?

Example of logs in mysqld.log file is given below.

180305 9:49:37 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed
180305 9:49:37 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed
180305 9:49:37 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed
180305 9:49:37 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed
180305 9:49:37 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed


Regards
Jatindeep Sharma

Re: delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 11:36 am
by scottwilkerson
This is showing that you actually have a database error, you should run the following repair procedure
https://assets.nagios.com/downloads/nag ... tabase.pdf


Once completed you can clear the log and free up the space by running the following:

Code: Select all

cat /dev/null > /var/log/mysqld.log

Re: delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 12:15 pm
by jatindeepsharma
Hello scottwilkerson,
Thanks for prompt reply.
For your information these error logs in mysqld.log file are from 2018, right now database is working fine & there is not any error in any of table(logentries, notifications & statehistory).
can i delete these logs by this command given below by you if everything is running fine & please also let me know do i have to stop mysqld service before running the command provided by you.

Regards
jatindeep sharma

Re: delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 12:42 pm
by scottwilkerson
Ok, you can do the following without stopping the service

Code: Select all

cat /dev/null > /var/log/mysqld.log
This clears the file while maintaining it's existence and proper permissions

Re: delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 1:18 pm
by jatindeepsharma
Thanks scottwilkerson for your help. I have deleted the same.

Regards
Jatindeep Sharma

Re: delete /var/log/mysqld.log on NAGIOS SQL server

Posted: Wed Jan 15, 2020 1:19 pm
by scottwilkerson
jatindeepsharma wrote:Thanks scottwilkerson for your help. I have deleted the same.

Regards
Jatindeep Sharma
Great!

Locking thread