How to change logrotate permissions for MariaDB error log from 640 to 644?
0
votes
1
answer
47
views
I need to change the read permissions from 640 to 644 so a different Linux user can access the MariaDB error log. My server's host uses CloudLinux and it is setup to use
logrotate
with the MariaDD error log. I'll mildly decent at find
and grep and that is how I figured out it was
logrotate` creating new files for each day. What the files look like in my FTP/SSH:
- /var/log/mysql.error.log
- /var/log/mysql.error.log-20250721
- /var/log/mysql.error.log-20250722
- /var/log/mysql.error.log-20250723
So logrotate
has two files that I think are relevant however I've done the one obvious thing a day ago and after 24 hours passed the new log file was created using 640 permissions instead of 644:
**/etc/logrotate.d/mariadb**
> /var/lib/mysql/mysqld.log /var/lib/mysql/mariadb.log
> /var/log/mariadb/*.log {
>
> \# Depends on a mysql@localhost unix_socket authenticated user with
> RELOAD privilege su mysql mysql
>
> \# If any of the files listed above is missing, skip them silently
> without # emitting any errors missingok
>
> \# If file exists but is empty, don't rotate it notifempty
>
> \# Run monthly monthly
>
> \# Keep 6 months of logs rotate 6
>
> \# If file is growing too big, rotate immediately maxsize 500M
>
> \# If file size is too small, don't rotate at all minsize 50M
>
> \# Compress logs, as they are text and compression will save a lot of
> disk space compress
>
> \# Don't compress the log immediately to avoid errors about "file
> size changed while zipping" delaycompress
>
> \# Don't run the postrotate script for each file configured in this
> file, but # run it only once if one or more files were rotated
> sharedscripts
>
> \# After each rotation, run this custom script to flush the logs.
> Note that # this assumes that the mariadb-admin command has database
> access, which it # has thanks to the default use of Unix socket
> authentication for the 'mysql' # (or root on Debian) account used
> everywhere since MariaDB 10.4. postrotate
> if test -r /etc/mysql/debian.cnf
> then
> EXTRAPARAM='--defaults-file=/etc/mysql/debian.cnf'
> fi
>
> if test -x /usr/bin/mariadb-admin
> then
> /usr/bin/mariadb-admin $EXTRAPARAM --local flush-error-log \
> flush-engine-log flush-general-log flush-slow-log
> fi endscript }
**/etc/logrotate.d/mariadb**
/var/log/mysql.error.log {
create 644 mysql root
notifempty
daily
rotate 5
missingok
nocompress
nocopytruncate
dateext
sharedscripts
postrotate
env HOME=/root/ /usr/bin/mysql -e 'flush logs'
endscript
So I changed the 640 to 644 in the **/etc/logrotate.d/mariadb** file and the file for the 23rd was still created using 640 permissions.
**How do I force logrotate
to create files using 644 permissions?**
In the interim I looked up other examples and for some reason my file was missing the closing }
, maybe that was the issue? However I'm not entirely sure, I'm only mildly versed in Linux and I don't want to wait 24 hours for *every* little thing to try or this will never get done!
Asked by John
(196 rep)
Jul 23, 2025, 10:51 AM
Last activity: Jul 23, 2025, 06:34 PM
Last activity: Jul 23, 2025, 06:34 PM