Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.