How to resolve "error creating output file XXX Permission denied" during logrotate execution
Issue
- The following error occurred during the execution of logrotate.
logrotate /etc/logrotate.d/tlog
error: error creating output file /test/testdir/bak/log/tlog.log_2023-06-03: Permission denied
- We can see that the secondary group of user tlog01 is set to tbak_gp, but logrotate still failed due to permission denied.
The associated settings are as follows:
# cat /etc/logrotate.d/tlog
/test/testdir/log/tlog.log
{
daily
rotate 90
dateext
dateformat _%Y-%m-%d
missingok
copytruncate
su tlog01 tlog_gp
olddir /test/testdir/bak/log
}
# ls -ld /test/testdir/bak/log/
drwxrwxr-x 2 tbak01 tbak_gp 6 Jun 14 14:11 /test/testdir/bak/log/
# id tlog01
uid=1005(tlog01) gid=1005(tlog01) groups=1005(tlog01),1008(tbak_gp)
# cat /etc/group | grep tlog_gp
tlog_gp:x:1006:
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Logrotate
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.