0

Logrotate is not rotating automatically, but it's working with logrotate -d and logrotate -f with no errors showing. But it's not running automatically each day. Below is the logrotate -d output.

logrotate -d  /etc/logrotate.d/lumen 
reading config file /etc/logrotate.d/lumen
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /var/www/*/storage/logs/*.log  after 1 days (365 rotations)
empty log files are rotated, old logs are removed
switching euid to 48 and egid to 48
considering log /var/www/testdir/storage/logs/laravel.log
  log needs rotating
rotating log /var/www/testdir/storage/logs/laravel.log, log->rotateCount is 365
Converted ' -%Y%m%d' -> '-%Y%m%d'
dateext suffix '-20190425'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
fscreate context set to unconfined_u:object_r:httpd_user_rw_content_t:s0
renaming /var/www/testdir/storage/logs/laravel.log to /var/www/testdir/storage/logs/laravel.log-20190425
switching euid to 0 and egid to 0
3
  • I can't remember if Centos uses a central /etc/logrotate.conf. It might be worth running logrotate -d /etc/logrotate.conf to see if the central config file has applied default defaults which are breaking things. Apr 25, 2019 at 8:12
  • You could also check to confirm that a daily cron job exists for logrotate under /etc/cron.daily. The variant of this job on my RHEL 7 system also shows that a log message is written if logrotate exits with a non-zero status. You can also look for that message in /var/log/messages.
    – Haxiel
    Apr 25, 2019 at 10:56
  • I ran the main one and no errors occurred. I also checked /var/lib/logrotate/logrotate.status and it seems to be not running only my scripts.
    – Pat
    Apr 25, 2019 at 13:59

2 Answers 2

0

You should check whether Cron is installed / a Cron Job is in place

0

I can't help noticing that you are rotating logs located under /var/www, and logrotate is emitting this SELinux-related message:

fscreate context set to unconfined_u:object_r:httpd_user_rw_content_t:s0

When you run logrotate manually from your unconfined session with admin privileges, it can certainly set the SELinux type to httpd_user_rw_content_t.

But a logrotate started by cron in a more restricted context might not be able to do that, unless you have taken steps to allow it.

At least on RHEL 7.9, with the selinux-policy-doc package installed, man logrotate_selinux does not list httpd_user_rw_content_t as related to logrotate in any way.

If you have a legitimate web application that requires that the rotated logs are writeable by httpd, and apparently also under the web server's document root, then you can certainly do so... but I can't help finding such a configuration somewhat risky, in a "come hack me and wipe my logs" sense.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .