0

I have the following entry in /etc/crontab

47 * * * * root /usr/sbin/logrotate -v -f /etc/logrotate.d/mariadb_dumps &> /tmp/errrot

The line is run because the /tmp/errrot if created (empty), however logrotate does nothing.

If I run the line on command line out of cron, it works fine and it outputs to /tmp/errrot.

The file /etc/logrotate.d/mariadb_dumps has:

/home/backups/alldbs.sql.gz {

rotate 48
create 640 root adm
notifempty
nocreate
}

Packages are:

cronie-1.4.11-19.el7.x86_64
cronie-anacron-1.4.11-19.el7.x86_64

OS is CentOS 7

What should I modify to run logrotate hourly?

Note: I've tried even putting the line in a separate file in /etc/cron.d and even setting a custom path for logrotate as in How to execute logrotate every hour. None of those approaches work.

2
  • 3
    It's a small point, but &> (as a redirection) is a bashism - are you sure cron is running jobs with bash (rather than POSIX sh)? if not, it may explain why the error file is empty Commented Jan 8, 2020 at 20:23
  • I sure running bash, it was a selinux issue Commented Jan 9, 2020 at 5:14

1 Answer 1

1

Finally, I've found it was a selinux issue, but it was somewhat hidden, so I run:

semodule --disable_dontaudit --build

then I've found those denials, I've created selinux modules for exception and applied and now it works fine.

Then, I've run:

semodule --build

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.