This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Logrotate for Sentora (Centos 6&7 Ubuntu & Debian)
#1
Logrotate for Sentora (Centos 6&7 Ubuntu & Debian)
Hello,

Here some code to rotate all the logs for domains and Sentora programs.

Make 3 files in thee logrotate.d directory:



Code:
vi /etc/logrotate.d/Sentora-apache

Paste:

Code:
/var/sentora/logs/domains/*/*access.log /var/sentora/logs/domains/*/*bandwidth.log /var/sentora/logs/domains/*/*error.log /var/sentora/logs/zpanel.log /var/sentora/logs/sentora*.log /var/sentora/logs/daemon*.log {
       weekly
       missingok
       rotate 2
       compress
       delaycompress
       create 640 apache apache
       sharedscripts
       postrotate
               systemctl reload httpd > /dev/null
       endscript
}


Code:
vi /etc/logrotate.d/Sentora-dovecot

Paste:

Code:
/var/log/dovecot*.log {
       weekly
       missingok
       rotate 5
       compress
       delaycompress
       notifempty
       create 666 vmail mail
       sharedscripts
       postrotate
               doveadm log reopen
       endscript
}

Code:
vi  /etc/logrotate.d/Sentora-proftpd


Paste:

Code:
/var/sentora/logs/proftpd/access.log /var/sentora/logs/proftpd/auth.log /var/sentora/logs/proftpd/xferlog.www {
       weekly
       missingok
       rotate 5
       compress
       delaycompress
       notifempty
       create 640 root adm
       sharedscripts
       postrotate
               # reload could be not sufficient for all logs, a restart is saf$
               systemctl reload proftpd >/dev/null
       endscript
}


You can finetune the settings if you want. For instance if you don't want always 5 copy's  of history you can set this to any value with rotate ...

For Ubuntu or Debian replace the postrotate rules:

Apache - postrotate /etc/init.d/apache2 reload > /dev/null
Proftpd - postrotate /etc/init.d/proftpd force-reload > /dev/null
Dovcecot - Stays the same

For Centos 6.x replace the postrotate rules with:

Apache - postrotate service httpd reload > /dev/null
Proftpd - postrotate service proftpd reload > /dev/null
Dovecot - Stays the same
[Image: logo2.png]

My being on this forum is all personal and all is done here by me has nothing to with the company Web Improved I work for Smile
Reply
Thanks given by: Castey , apinto
#2
RE: Logrotate for Sentora Centos 7
Hi all, i have some 1.5GB logs that webalizer takes to long to process making my vps running slow, does anyone tried adapting this bbspike logrotate confing to ubuntu i believe that at least the prerotate script must be changes, am i wright?
Thanks
Reply
Thanks given by:
#3
RE: Logrotate for Sentora Centos 7
most of the log path are the same in ubuntu and sure over domains logs.

We plan to add it in sentora install/update too.
M B
No support using PM (Auto adding to IGNORE list!), use the forum. 
How to ask

200$ free to start your VPS 60 days credit
Reply
Thanks given by:
#4
RE: Logrotate for Sentora Centos 7
I just made some ajustments for ubuntu on the sentora-apache it was just needed to replace  the postrotate for adapting to ubuntu's service

Code:
/var/sentora/logs/domains/*/*access.log /var/sentora/logs/domains/*/*error.log /var/sentora/logs/zpanel.log /var/sentora/logs/sentora*.log /var/sentora/logs/daemon*.log {
      weekly
      missingok
      rotate 5
      compress
      delaycompress
      create 640 root adm
      sharedscripts
      postrotate
             service apache2 reload > /dev/null
      endscript
      prerotate
              if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                      run-parts /etc/logrotate.d/httpd-prerotate; \
              fi; \
      endscript
}
Reply
Thanks given by:
#5
RE: Logrotate for Sentora Centos 7
(02-24-2016, 10:13 AM)barreiras Wrote: I just made some ajustments for ubuntu on the sentora-apache it was just needed to replace  the postrotate for adapting to ubuntu's service

Code:
/var/sentora/logs/domains/*/*access.log /var/sentora/logs/domains/*/*error.log /var/sentora/logs/zpanel.log /var/sentora/logs/sentora*.log /var/sentora/logs/daemon*.log {
      weekly
      missingok
      rotate 5
      compress
      delaycompress
      create 640 root adm
      sharedscripts
      postrotate
             service apache2 reload > /dev/null
      endscript
      prerotate
              if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                      run-parts /etc/logrotate.d/httpd-prerotate; \
              fi; \
      endscript
}

For Debain and Ubuntu also look into the create line, they may use other permissions.
[Image: logo2.png]

My being on this forum is all personal and all is done here by me has nothing to with the company Web Improved I work for Smile
Reply
Thanks given by:
#6
RE: Logrotate for Sentora (Centos 6&7 Ubuntu & Debian)
Updated the first post with new rules and adding Ubuntu and Debian rules.
[Image: logo2.png]

My being on this forum is all personal and all is done here by me has nothing to with the company Web Improved I work for Smile
Reply
Thanks given by:
#7
RE: Logrotate for Sentora (Centos 6&7 Ubuntu & Debian)
Having some problems with this.

This is my apache logrotate. Slightly tweaked from the OPs:

Code:
/var/sentora/logs/domains/*/*access.log /var/sentora/logs/domains/*/*bandwidth.log /var/sentora/logs/domains/*/*error.log /var/sentora/logs/zpanel.log /var/sentora/logs/sentora*.log /var/sentora/logs/daemon*.log {
       weekly
       missingok
       rotate 4
        create 640 www-data www-data
       sharedscripts
       postrotate
        /etc/init.d/apache2 reload > /dev/null
       endscript
}

When do a test run for this log with

Code:
logrotate -df /etc/logrotate/sentora-apache

I get lots of errors like this:

Code:
error: skipping "/var/sentora/logs/domains/reseller/somedomain.com-error.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

So I checked the permissions on the directory "reseller":

Code:
drwxrwxrwx 2 root root  4096 Mar 15 14:16 reseller

Ok, odd that it's owned by root:root and not www-data but since it's world writable I can see apache can make files in there.

But it gets weirder. The permissions on the files in the directory are all as such:

Code:
-rw-rw-r-- 1 root root         234 Jan  7 15:40 somedomain.com-error.log

They are owned by root with only root allowed to write to them. Yet apache is writing to them just fine. I checked that www-data is not in root's group.

AFAIK these are the defaults from the Sentora installation. I have not changed anything manually.

So two questions:
   - What does the logrotate error really mean and how can I fix it without breaking sentora?
   - How is apache able to write to the log files when they are owned by root:root?

EDIT:

Solved my problem. Apparently when a rotate is run manually logrotate doesn't know who to run as to do the rotation and so it needs specifying the config file. Now my config looks like this:

Code:
/var/sentora/logs/domains/*/*access.log /var/sentora/logs/domains/*/*bandwidth.log /var/sentora/logs/domains/*/*error.log /var/sentora/logs/zpanel.log /var/sentora/logs/sentora*.log /var/sentora/logs/daemon*.log {
       su root syslog
       weekly
       missingok
       rotate 4
        create 640 www-data www-data
       sharedscripts
       postrotate
        /etc/init.d/apache2 reload > /dev/null
       endscript
}

Rotate seems to be working fine and apache is writing to the new log files.
Reply
Thanks given by:
#8
RE: Logrotate for Sentora (Centos 6&7 Ubuntu & Debian)
For those using Ubuntu and having trouble with the above examples, I have gotten things working and posted the configuration here: http://forums.sentora.org/showthread.php...2#pid16282

I changed a few of the lines, matched the permissions with what was setup by Sentora and added a check for filesize.
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
Secure Sentora Domains with Let's Encrypt TGates 27 97 ,153 06-08-2024, 05:06 PM
Last Post: andykimpe
Upgrade to Ubuntu 16.04 from 14.04 HogensHero 8 30 ,324 07-18-2020, 03:13 AM
Last Post: dycott78
Ubuntu: How to Enable tls/ssl in proftpd Diablo925 2 12 ,834 04-21-2020, 03:35 AM
Last Post: iraqiboy90

Forum Jump:


Users browsing this thread: 2 Guest(s)