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.

| improve this question | | | | |
  • 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 – steeldriver Jan 8 at 20:23
  • I sure running bash, it was a selinux issue – sebelk Jan 9 at 5:14
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

| 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.