I am trying to figure out what is causing anacron to send me the following error message:


/var/log/mariadb/mariadb.log-20140710.gz: Permission denied
error: error running last action script for /var/log/mariadb/*.log

These are the relevant configs:

# /etc/cron.d
01 * * * * root run-parts /etc/cron.hourly
# /etc/cron.hourly/0anacron
/usr/sbin/anacron -s
# /etc/anacrontab
1   5   cron.daily      nice run-parts /etc/cron.daily
# /etc/cron.daily/logrotate
/usr/sbin/logrotate /etc/logrotate.conf
# /etc/logrotate.conf
include /etc/logrotate.d

This is the main config in question:

# /etc/logrotate.d/mariadb

/var/log/mariadb/*.log {
  create 640 mysql mysql



    today=$(date -u +%Y%m%d)
    attach1=$(ls -t1 ${dir}mariadb*gz 2>&1 head -1 | grep $today)

    if [[ $attach1 ]]; then
     attachment+=" -a $attach1"
     totalsize=$((totalsize + $(stat -c %s $attach1)))

When I tested the above on commandline with # logrotate -f /etc/logrotate.conf, there is no error. But when anacron is running it, it gets permission denied error as shown above. I am guessing that the error is generated when it runs the stat command.

I have the following permission setting for the file in question

-rw-r-----. mysql mysql system_u:object_r:mysqld_log_t:s0 mariadb.log-20140711.gz

The SELinux context looks fine to me and I don't see any avc error in my journal log, so it shouldn't be due to SELinux. Also, from cron.d, run-parts is executed with root as user, so there shouldn't be a permission problem.

I have read this question of which the recommendation is to do strace. But I don't have strace and I am not allowed to install it. Is there anyone who can tell me what is causing the permission error?


Just went through this with clamd. Make sure that the user running logrotate has permission to write to /var/log/mariadb.

Try su root root at the top of the configuration directive.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.