How to get cron to delete a big logfile? - Mandriva

This is a discussion on How to get cron to delete a big logfile? - Mandriva ; Hi, I wonder if there is a way to get cron to delete a log file before it grows too big? The log file in question is /var/log/mail/info and I check up my router machine with webmin. I check my ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: How to get cron to delete a big logfile?

  1. How to get cron to delete a big logfile?

    Hi,
    I wonder if there is a way to get cron to delete a log file before it
    grows too big? The log file in question is /var/log/mail/info and I
    check up my router machine with webmin. I check my log file from time to
    time, and I reckon that the log file should be in a "new" state every
    week, but on my router machine the log file was from the 4 of December
    last year, almost 1 Mb with information from spamassassin and postfix.
    I have now deletet the log record by hand, but I would like to know if
    there is a way getting Cron to do that, before it grows too big?

    All the best

    Roger
    --
    Mandriva Linux 2008 (Linuxcounter #432950)

    MSI K8TM, 1,0 Gb Memory, AMD Sempron 3000+ CPU
    ATI Sapphire Radeon X1600
    __________________________________________________
    Be against others the way
    you want to be treated yourself

  2. Re: How to get cron to delete a big logfile?

    On Sat, 09 Feb 2008 13:02:31 -0500, Roger wrote:

    > Hi,
    > I wonder if there is a way to get cron to delete a log file before it
    > grows too big? The log file in question is /var/log/mail/info and I


    Try adding an entry to /etc/logrotate.conf

    Regards, Dave Hodgins

    --
    Change nomail.afraid.org to ody.ca to reply by email.
    (nomail.afraid.org has been set up specifically for
    use in usenet. Feel free to use it yourself.)

  3. Re: How to get cron to delete a big logfile?

    On Sat, 09 Feb 2008 19:02:31 +0100, Roger wrote:
    > Hi,
    > I wonder if there is a way to get cron to delete a log file before it
    > grows too big?


    Yes.

    Determine if you want to check hourly or daily and place script or
    link to script in either /etc/cron.hourly or /etc/cron.daily.

    The script could use "stat" to get file size.
    "if statement" to see if greater than some value.
    If so, use "service" to stop daemon/service(s) using log file(s),
    cp /dev/null /var/log/mail/file_2_replace and
    "service" to start daemon/service(s)


    For extra points,
    man stat
    man service
    http://tldp.org/LDP/abs/html/index.html


  4. Re: How to get cron to delete a big logfile?

    Roger wrote:

    > Hi,
    > I wonder if there is a way to get cron to delete a log file before it
    > grows too big? The log file in question is /var/log/mail/info and I
    > check up my router machine with webmin. I check my log file from time to
    > time, and I reckon that the log file should be in a "new" state every
    > week, but on my router machine the log file was from the 4 of December
    > last year, almost 1 Mb with information from spamassassin and postfix.
    > I have now deletet the log record by hand, but I would like to know if
    > there is a way getting Cron to do that, before it grows too big?


    Are you running Mandriva 2008? Did you upgrade from an earlier version
    around December 4 2007?

    This version renamed the mail log files; instead of info, errors and
    warnings they are now info.log, errors.log and warnings.log. The
    logrotate script of course rotates the new file names, but if you've
    upgraded from an older Mandriva version and had custom rules in
    syslog.conf then the old file names will still be there and will
    gradually grow as there is nothing to rotate them.
    --
    Dave
    (who got bitten by the same problem)


  5. Re: How to get cron to delete a big logfile? SOLVED

    Dave Pickles skrev:
    > Roger wrote:
    >
    >> Hi,
    >> I wonder if there is a way to get cron to delete a log file before it
    >> grows too big? The log file in question is /var/log/mail/info and I
    >> check up my router machine with webmin. I check my log file from time to
    >> time, and I reckon that the log file should be in a "new" state every
    >> week, but on my router machine the log file was from the 4 of December
    >> last year, almost 1 Mb with information from spamassassin and postfix.
    >> I have now deletet the log record by hand, but I would like to know if
    >> there is a way getting Cron to do that, before it grows too big?

    >
    > Are you running Mandriva 2008? Did you upgrade from an earlier version
    > around December 4 2007?
    >

    Yes =0)
    > This version renamed the mail log files; instead of info, errors and
    > warnings they are now info.log, errors.log and warnings.log. The
    > logrotate script of course rotates the new file names, but if you've
    > upgraded from an older Mandriva version and had custom rules in
    > syslog.conf then the old file names will still be there and will
    > gradually grow as there is nothing to rotate them.



    Thx to you and the rest who gave me advices, I took your advice and
    found excactly what you said. I removed the *.log extension, think that
    the problem is solved now.

    Greetings from a rainy and foggy southern Norway, instead frost there's
    5 +C outside here in Aurskog, close to Oslo..The weather has gone
    completely bananas.

    Thanks to all.

    Roger

    --
    Mandriva Linux 2008 (Linuxcounter #432950)

    MSI K8TM, 1,0 Gb Memory, AMD Sempron 3000+ CPU
    ATI Sapphire Radeon X1600
    __________________________________________________
    Be towards others the way
    you want to be treated yourself

  6. Re: How to get cron to delete a big logfile? SOLVED

    On Sat, 09 Feb 2008 22:00:29 +0100, Roger wrote:
    >
    > Thx to you and the rest who gave me advices, I took your advice and
    > found excactly what you said. I removed the *.log extension, think that
    > the problem is solved now.


    Yes that would be for now. Next posfix start will write to *.log files.
    I assume you deleted /info (old name) instead of info.log (new name).
    Now if you just deleted *.log, postfis would still be writing to any
    open files you deleted. A
    service postfix restart
    would straighten that up.

    > Greetings from a rainy and foggy southern Norway,


    Here in Dallas Texas, USA it's a sunny 70 degrees.

  7. Re: How to get cron to delete a big logfile? SOLVED


    > Yes that would be for now. Next posfix start will write to *.log files.
    > I assume you deleted /info (old name) instead of info.log (new name).
    > Now if you just deleted *.log, postfis would still be writing to any
    > open files you deleted. A
    > service postfix restart
    > would straighten that up.


    Did as you told me, hope for the best..

    >
    >> Greetings from a rainy and foggy southern Norway,

    >
    > Here in Dallas Texas, USA it's a sunny 70 degrees.


    Wow..

    Roger


    --
    Mandriva Linux 2008 (Linuxcounter #432950)

    MSI K8TM, 1,0 Gb Memory, AMD Sempron 3000+ CPU
    ATI Sapphire Radeon X1600
    __________________________________________________
    Be towards others the way
    you want to be treated yourself

+ Reply to Thread