Translated message

A translation of this page exists in English.

logrotate はログメッセージをローテーションしても、圧縮はしない (cron ジョブとして)

Solution In Progress - Updated -

Issue

logrotate が cron ジョブとして実行されると、foo.service のログファイルをローテーションするだけで、圧縮は行われません。

logrotate の cron ジョブ実行時に、/var/log/messages または journal において、以下のエラーメッセージが検出されました。
logrotate: ALERT exited abnormally with [1]

また、/var/log/audit/audit.log には以下の selinux 拒否が記録されていました。

type=USER_AVC msg=audit(1539689401.569:2897): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { status } for auid=0 uid=0 gid=0 path="/etc/rc.d/init.d/foo" cmdline="systemctl show foo.service" scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:etc_t:s0 tclass=service  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1539689401.673:2898): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { start } for auid=0 uid=0 gid=0 path="/etc/rc.d/init.d/foo cmdline="/bin/systemctl restart awslogs.service" scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:etc_t:s0 tclass=service  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'

foo.service の logrotate 設定ファイルは、以下のとおりです。

$ cat /etc/logrotate.d/foo
/var/log/foo.log {
    missingok
    notifempty
    size 100K
    create 0600 root root
    compress
    rotate 4
    postrotate
        /etc/init.d/foo restart > /dev/null
    endscript
}

同時に、logrotate を手動で実行すると、ログのローテーションと圧縮が正常に行われます。

# logrotate -fv /etc/logrotate.conf

Environment

Red Hat Enterprise Linux 7
- selinux enforcing
- logrotate

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content