Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    logrotate configuration


    Hi want to rotate a log every day, zip it and move to another folder.
    the file name is like this :
    client-server.2017-05-22.log
    i want to zip all except today log!
    how to do it?

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,992
    Obviously these logs are already rotated.
    To process them again with logrotate would create duplicate logic.

    I would look into the configuration of whatever currently rotates these logs (is it a java log appender? ) and see if it is possible to configure a max number of rotated files.
    If not, create a cronjob to clean them. The date command along with the identifiable filename make that rather easy to implement.

    edit: max number, not max size of rotated files
    Last edited by Irithori; 10-27-2017 at 12:10 PM.
    You must always face the curtain with a bow.

  3. #3
    your correct.
    i thought maybe to use logrotate for
    1. zipping the rotated log
    2. moving it to another folder
    but it seems more simple to use BASH script

    another question - can i rotate a log that a service writes too, but it won't stop he service from working?
    i have a service that write to log like this :
    PHP Code:

    nohup java 
    -jar $PATH_TO_JAR /tmp 2>> $LOG_FOLDER/server.log >> $LOG_FOLDER/server.log & echo $! > $PID_PATH_NAME 
    is there a way to handle it?

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,992
    As server.log is a created by shell redirection and is therefore a continuous stream, you could use logrotate and its copytruncate option for it.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •