The pfSense Store

Author Topic: postfix log  (Read 1852 times)

0 Members and 1 Guest are viewing this topic.

Offline tritron

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
postfix log
« on: July 12, 2012, 07:41:25 pm »
I have switched to firebox and i run post fix and var is about 50 to 60 mb in size.  it seems that postfix log file grows taking up most of free space.
I wonder if there is option that prevents postfix from creating such large log file and is there command that will tell file system that space was freedup by deleting log.

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: postfix log
« Reply #1 on: July 12, 2012, 10:41:10 pm »
I did not included a log rotate options to this package,

try to use logrotate daemon with cron jobs

https://iamsto.wordpress.com/2012/03/24/freebsd-logrotate-add-new-file/

Online LinuxTracker

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
    • View Profile
Re: postfix log
« Reply #2 on: August 31, 2012, 04:35:14 pm »
I did not included a log rotate options to this package,

try to use logrotate daemon with cron jobs

https://iamsto.wordpress.com/2012/03/24/freebsd-logrotate-add-new-file/

I thought that was a pretty good idea and set about to install logrotate.  I'm running 2.0.1-RELEASE (i386) btw.

From the above link:
Quote
1. Install logrotate

    #cd /usr/ports/sysutils/logrotate/
    #make install clean clean-depends

Problem is /usr/ports doesn't exist.  I looked for sysutils or logrotate but they weren't in there either.
Other problem is that there's no 'make' native to pfSense - except maybe in dev branches.

So what about installing logrotate from the repositories?

Well,
Other other problem is that my default repository (ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest/) has been archived by the FreeBSD folks.
I think it's at http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.1-release/Latest/

Other other other problem is that a lot of my existing installed-package-dependencies are newer than the dependencies required by packages in 8.1-release.
Maybe packages from release-8.1-stable (http://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/Latest) or later would work.

Other other other other problem is that logrotate doesn't exist in the FreeBSD repository for any version of 8.1 (i386) anyway.

My solution:
Code: [Select]
pkg_add -r http://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.2-release/sysutils/logrotate-3.7.9.tbz
I installed it.  So far nothing's blown up.


Edit: I should add that I
Code: [Select]
cp /usr/local/etc/logrotate.conf.sample /etc/logrotate.conf to get started.

« Last Edit: August 31, 2012, 05:00:19 pm by LinuxTracker »

Online LinuxTracker

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
    • View Profile
Re: postfix log
« Reply #3 on: September 18, 2012, 05:10:46 pm »
After a very long time, I finally got logrotate working.
Here's how I have it configured.

I created /archives directory to hold archived postfix logs.

The /usr/local/etc/logrotate.d directory is empty.

I created /etc/logrotate.conf, and am using it for the config file.
Here's what's in it.
Code: [Select]
# location of archived log files
olddir /archives

/var/log/maillog {
        # rotate logs daily (at midnight via cron)
        daily

        # don't complain if log is missing
        missingok

        # keep a month's worth of logfiles
        rotate 30

        # compress all but yesterday's logs with gzip
        compress
        delaycompress

        # in case log file in use by process, truncates log file then copies it
        copytruncate

        # create new empty log file w/ same permissions as old log file (unsure if needed)
        create 644 root wheel

        # date appended onto archived log names
        dateext

        # beats me - this was already here
        sharedscripts

        # restart postifx
        postrotate
          /etc/init.d/postfix reload > /dev/null 2>&1 || true

        endscript
      }

# system-specific logs may be configured here

Here's the cron command I run at midnight:
Code: [Select]
/usr/local/sbin/logrotate -f -s /archives/logrotate.status /etc/logrotate.conf
-f = Forces logrotate to run.
I had to use it for testing.  Once my logrorate.status file is populated, I might not need it any more.

-s = sets the status file to be in the /archives directory
I'm not sure what the default directory is.


I'm guessing if I could use this cron entry instead, if I wanted verbose command output from the cron job:
Code: [Select]
/usr/local/sbin/logrotate -f -v -s /archives/logrotate.status /etc/logrotate.conf >> /archives/logrotate.logI haven't tried it yet, however.



I hope this saves someone lots of time.

« Last Edit: September 18, 2012, 05:15:31 pm by LinuxTracker »

Offline DQM

  • Jr. Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: postfix log
« Reply #4 on: September 22, 2012, 08:31:35 am »
Hi LinuxTracker,

I have followed up your steps to configure the logrotate for PF. I'd like to show you in deatails as below. Pls help to re-check and confirm if it is correct.

Step1: run command to install the logrotate
pkg_add -r http://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.2-release/sysutils/logrotate-3.7.9.tbz ( I'm using 2.0.1 RELEASE (amd64) built on Mon Dec 12 18:16:13 EST 2011 FreeBSD 8.1-RELEASE-p6)

Setp2: Create Archives folder at /archives to store the archiving log. I have also created folder logrotate.d at /usr/local/etc/logrotate.d ( I don't know its function. Could you explain?)

Step3: Create file /etc/logrotate.conf with content below:

Quote
# location of archived log files
olddir /archives

/var/log/maillog {
        # rotate logs daily (at midnight via cron)
        daily

        # don't complain if log is missing
        missingok

        # keep a month's worth of logfiles
        rotate 30

        # compress all but yesterday's logs with gzip
        compress
        delaycompress

        # in case log file in use by process, truncates log file then copies it
        copytruncate

        # create new empty log file w/ same permissions as old log file (unsure if needed)
        create 644 root wheel

        # date appended onto archived log names
        dateext

        # beats me - this was already here
        sharedscripts

        # restart postifx
        postrotate
          /etc/init.d/postfix reload > /dev/null 2>&1 || true

        endscript
      }

# system-specific logs may be configured here

Step4: I have tried to run the command /usr/local/sbin/logrotate -f -s /archives/logrotate.status /etc/logrotate.conf on shell console and it seems to work well.

I have also installed Cron package and created a cron job. I want this job will run at 12:00 AM daily. But I still didn't clear the time (minute, hour, mday, ...) of cron job. Below is my cron job configuration:

Quote
minute: 0
hour: 24
mday: *
month: *
wday: *
who: root
command: /usr/local/sbin/logrotate -f -s /archives/logrotate.status /etc/logrotate.conf

Is it correct? (daily run at midnight)

P/S: I'm not a linux/*nix professional  >:(
Thank you,
DQM
« Last Edit: September 22, 2012, 08:35:49 am by DQM »