mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
13.98k stars 1.44k forks source link

Huge Log files, logrotate not working #1656

Open RandyR716 opened 5 years ago

RandyR716 commented 5 years ago

Hello all, I'm running a stock Miab install on 50gb DO 18.04. I recently noticed on the status page that only 8.6gb remains available. I only have 3 users and no ones mailbox is over a gig, my total /home/user-data/mail directory with all the mailboxes is only 1.9gb. the owncloud folder is 9.6gb with 8.8gb being the nextcloud.log file. (so 0.8 gb owncloud usage)There is also an owncloud.log file thats 1gb.

The server has been running since 2015 or so, was migrated to 18.04 at the time of that update. My system is on the current version.
So in an attempt to fix some of this on my own, I created a logrotate entry for nextcloud - sudo nano /etc/logrotate.d/nextcloud

/home/user-data/owncloud/nextcloud.log { monthly rotate 6 compress delaycompress missingok notifempty su www-data www-data create 640 www-data www-data }

after I saved the above file, I ran: sudo logrotate --force /etc/logrotate.d/nextcloud

i did some further digging, and none of my Logrotate.d conf files are working. Some program in my box (postfix?) changed the ownership from root root to root syslog in my /var/log directory. Logrotate was skipping all the conf files as the ownership was something other than root root. I had to manually input a su line ( su root syslog) in each .conf file, otherwise they are skipped due to insecure permissions. I freed up 30gb of old log files.

I'm not much of a coder, I know just enough to be moderately dangerous. However I believe this may be affecting other users, as my box is stock. I believe the install script needs a logrotate entry for nextcloud added as well as either tracking down the ownership change in /var/log or adding a su line in all of the .conf files. I see a lot of requests for mailbox size limits and I'm wondering if the problem isnt the mailbox sizes but simply the log files. Thank you everyone for your time.

jvolkenant commented 5 years ago

I didn't know until I saw this https://github.com/nextcloud/server/issues/5165

Nextcloud has a built in log rotating mechanism.

What happens when you run the following:

root@m:~/mailinabox# sudo -u www-data php /usr/local/lib/owncloud/occ log:file
Log backend file: enabled
Log file: /home/user-data/owncloud/nextcloud.log
Rotate at: 100 MB

I did not have to set this (I believe it is the default) You can set the rotation size by:

sudo -u www-data php /usr/local/lib/owncloud/occ log:file --rotate-size 100MB
RandyR716 commented 5 years ago

I get the same output. However it isnt working. the Logfile is back up to a gig. sudo -u www-data php /usr/local/lib/owncloud/occ log:file Log backend file: enabled Log file: /home/user-data/owncloud/nextcloud.log Rotate at: 100 MB

jvolkenant commented 5 years ago

setup/nextcloud.sh sets correct permissions for that path so it should not be a permissions problem.

Mine seems to be acting normally. I wonder if others are having this same problem too.

root@m:~# ls -la /home/user-data/owncloud/nextcloud.log*
-rw-r----- 1 www-data www-data  81590299 Oct 17 23:21 /home/user-data/owncloud/nextcloud.log
-rw-r----- 1 www-data www-data 106168995 Oct 10 01:16 /home/user-data/owncloud/nextcloud.log.1
aviallon commented 1 year ago

Hello, my logrotate isn't working either:

$ occ log:file
Log file: /var/log/nextcloud/nextcloud.log
Rotate at: 10 MB
$ ls -lh data/nextcloud.log
-rw-r----- 1 www-data 1000 51.4G Nov 19 15:44 data/nextcloud.log

That is quite giganormous.

Pseudodevincent commented 1 year ago

Hello, my logrotate isn't working either:

$ occ log:file
Log file: /var/log/nextcloud/nextcloud.log
Rotate at: 10 MB
$ ls -lh data/nextcloud.log
-rw-r----- 1 www-data 1000 51.4G Nov 19 15:44 data/nextcloud.log

That is quite giganormous.

Same problem for me...

$ occ log:file
Log backend file: enabled
Log file: data/nextcloud.log
Rotate at: 100 MB
$ sudo ls -lh data/nextcloud.log
-rw-r----- 1 www-data www-data 39G  7 janv. 23:47 data/nextcloud.log