7

Recently I've noticed that logrotate does not rotate my logs.

user1@host:~$ /usr/sbin/logrotate /home/user1/logrotate.conf -v gives me an error:

error: error setting owner of /home/logs/mylog.log.1 to uid 10111 and gid 10111: 
Operation not permitted
error: error creating output file /var/lib/logrotate/status.tmp:
Permission denied

That gid confuses me, as user1 is only a member of a group with different gid:

user1@host:~$ id
uid=10111(user1) gid=1001(mygroup) groups=1001(mygroup)

However, there's another group called user1, but, as I mentioned, actual user user1 is not its member:

user1@host:~$ cat /etc/group | grep user1
user1:x:10111

It's something simple here, but I can't see it.

UPDATE: here's what logrotate.conf looks like:

/home/logs/*.log { rotate 7 daily copytruncate compress notifempty }

user1@host:~$ ls -al /home/logs/ -rw-r--r-- 1 user1 mygroup 190826983 Dec 18 06:05 mylog.log

hdf
  • 171
  • 1
  • 1
  • 4

1 Answers1

1

You can try using logrotates create directive to set the permissions of the newly created log file. To use it you

/home/logs/*.log {
    rotate 7
    daily
    create 0777 user1 user1
    ^^^^^^^^^^^^^^^^^^^^^^
    copytruncate
    compress
    notifempty
 }

From man logrotate

 create mode owner group, create owner group

Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log file just rotated). mode specifies the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same values as the original log file for the omitted attributes. This option can be disabled using the nocreate option.