Page 1 of 1

logrotate mysqld errors

Posted: Tue Oct 16, 2018 11:46 pm
by chrisf
I'm on Ubuntu 18.04, and I keep getting an email everynight saying logrotate failed due to:

/etc/cron.daily/logrotate: logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator

I can't track this down... some help please?

Re: logrotate mysqld errors

Posted: Wed Oct 17, 2018 12:16 am
by chrisf
For further information I can run

logrotate /etc/logrotate.conf --debug

And there is no error. I can am unable to find this.

Hope for help. :-)

Re: logrotate mysqld errors

Posted: Wed Oct 17, 2018 1:04 am
by chrisf
For anyone else having this problem, I have to add it was MariaDB... not mysql 5.7

I figured it out.

In /etc/logrotate.d/mysql-server there was the line:

Code: Select all

my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"
Which produces two matches, causing the error. Simple fix is m1 attribute added to grep:

Code: Select all

my_print_defaults --mysqld | grep -oPm1 "pid-file=\K[^$]+" 
Now all runs perfectly :-)