logrotate continues to rotate & compress already rotated logs

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I have a log that generates a new log file each day. Here is a listing of each log created since I turned on logging:



2019-01-04
2019-01-05
2019-01-06
2019-01-07
2019-01-08


This is the logrotate configuration. I have tried several iterations none of which result in the log being compressed and then "left alone" until it rolls off (hopefully in 90 days).



/etc/logrotate.d/remote

/var/log/remote/*/*[!.]gz
/var/log/remote/*/*.[!g]z
/var/log/remote/*/*.g[!z]
/var/log/remote/*/*[!.][!g]z
/var/log/remote/*/*[!.]g[!z]
/var/log/remote/*/*.[!g][!z]
/var/log/remote/*/*[!.][!g][!z]

rotate 90
daily
missingok
compress



This is a listing of the folder showing what logrotate is doing.



drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
-rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-04
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
-rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-04.2.gz
-rw-r----- 1 root adm 5.2K Jan 4 23:57 2019-01-04.3.gz
-rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-05
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
-rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-05.2.gz
-rw-r----- 1 root adm 7.4K Jan 5 23:58 2019-01-05.3.gz
-rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-06
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
-rw-r----- 1 root adm 8.0K Jan 6 23:56 2019-01-06.2.gz
-rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-07
-rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
-rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08


I want to manage the number of days of logs that are retained and while I'm at it, compress the old logs. This is what I want to end up with:



drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
-rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
-rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
-rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08









share|improve this question


























    1















    I have a log that generates a new log file each day. Here is a listing of each log created since I turned on logging:



    2019-01-04
    2019-01-05
    2019-01-06
    2019-01-07
    2019-01-08


    This is the logrotate configuration. I have tried several iterations none of which result in the log being compressed and then "left alone" until it rolls off (hopefully in 90 days).



    /etc/logrotate.d/remote

    /var/log/remote/*/*[!.]gz
    /var/log/remote/*/*.[!g]z
    /var/log/remote/*/*.g[!z]
    /var/log/remote/*/*[!.][!g]z
    /var/log/remote/*/*[!.]g[!z]
    /var/log/remote/*/*.[!g][!z]
    /var/log/remote/*/*[!.][!g][!z]

    rotate 90
    daily
    missingok
    compress



    This is a listing of the folder showing what logrotate is doing.



    drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
    drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
    -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-04
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
    -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-04.2.gz
    -rw-r----- 1 root adm 5.2K Jan 4 23:57 2019-01-04.3.gz
    -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-05
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
    -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-05.2.gz
    -rw-r----- 1 root adm 7.4K Jan 5 23:58 2019-01-05.3.gz
    -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-06
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
    -rw-r----- 1 root adm 8.0K Jan 6 23:56 2019-01-06.2.gz
    -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-07
    -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
    -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08


    I want to manage the number of days of logs that are retained and while I'm at it, compress the old logs. This is what I want to end up with:



    drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
    drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
    -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
    -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
    -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08









    share|improve this question
























      1












      1








      1








      I have a log that generates a new log file each day. Here is a listing of each log created since I turned on logging:



      2019-01-04
      2019-01-05
      2019-01-06
      2019-01-07
      2019-01-08


      This is the logrotate configuration. I have tried several iterations none of which result in the log being compressed and then "left alone" until it rolls off (hopefully in 90 days).



      /etc/logrotate.d/remote

      /var/log/remote/*/*[!.]gz
      /var/log/remote/*/*.[!g]z
      /var/log/remote/*/*.g[!z]
      /var/log/remote/*/*[!.][!g]z
      /var/log/remote/*/*[!.]g[!z]
      /var/log/remote/*/*.[!g][!z]
      /var/log/remote/*/*[!.][!g][!z]

      rotate 90
      daily
      missingok
      compress



      This is a listing of the folder showing what logrotate is doing.



      drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
      drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-04
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
      -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-04.2.gz
      -rw-r----- 1 root adm 5.2K Jan 4 23:57 2019-01-04.3.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-05
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
      -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-05.2.gz
      -rw-r----- 1 root adm 7.4K Jan 5 23:58 2019-01-05.3.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-06
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
      -rw-r----- 1 root adm 8.0K Jan 6 23:56 2019-01-06.2.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-07
      -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
      -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08


      I want to manage the number of days of logs that are retained and while I'm at it, compress the old logs. This is what I want to end up with:



      drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
      drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
      -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
      -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08









      share|improve this question














      I have a log that generates a new log file each day. Here is a listing of each log created since I turned on logging:



      2019-01-04
      2019-01-05
      2019-01-06
      2019-01-07
      2019-01-08


      This is the logrotate configuration. I have tried several iterations none of which result in the log being compressed and then "left alone" until it rolls off (hopefully in 90 days).



      /etc/logrotate.d/remote

      /var/log/remote/*/*[!.]gz
      /var/log/remote/*/*.[!g]z
      /var/log/remote/*/*.g[!z]
      /var/log/remote/*/*[!.][!g]z
      /var/log/remote/*/*[!.]g[!z]
      /var/log/remote/*/*.[!g][!z]
      /var/log/remote/*/*[!.][!g][!z]

      rotate 90
      daily
      missingok
      compress



      This is a listing of the folder showing what logrotate is doing.



      drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
      drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-04
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
      -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-04.2.gz
      -rw-r----- 1 root adm 5.2K Jan 4 23:57 2019-01-04.3.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-05
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
      -rw-r----- 1 root adm 20 Jan 6 06:25 2019-01-05.2.gz
      -rw-r----- 1 root adm 7.4K Jan 5 23:58 2019-01-05.3.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-06
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
      -rw-r----- 1 root adm 8.0K Jan 6 23:56 2019-01-06.2.gz
      -rw-r----- 1 root adm 0 Jan 8 06:25 2019-01-07
      -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
      -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08


      I want to manage the number of days of logs that are retained and while I'm at it, compress the old logs. This is what I want to end up with:



      drwxr-xr-x 2 root root 4.0K Jan 8 06:25 ./
      drwxr-xr-x 6 root root 4.0K Jan 4 09:44 ../
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-04.1.gz
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-05.1.gz
      -rw-r----- 1 root adm 20 Jan 7 06:25 2019-01-06.1.gz
      -rw-r----- 1 root adm 7.8K Jan 7 23:55 2019-01-07.1.gz
      -rw-r----- 1 root adm 101K Jan 8 13:16 2019-01-08






      logrotate






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 8 at 18:35









      Mike IngrahamMike Ingraham

      61




      61




















          2 Answers
          2






          active

          oldest

          votes


















          1














          You basically want to rotate log files that end with a digit in the specified directory, so the log matching becomes:



          /var/log/remote/*/*[0-9]


          A problem you're running into is that logrotate probably has the create option set as default, meaning that after a logfile is rotated (meaning it is renamed and maybe compressed), a new logfile with the original name is created. This can be prevented by using the nocreate option.



          However, you biggest problem is that your logfiles don't have a fixed name. logrotate keeps X versions of logfiles that have the same name; as the name changes every day, logrotate keeps one version of each day, so nothing ever gets removed.



          It might work if you could convince whatever is creating these logfiles to have some prefix like "log-" so that the names become "log-2019-01-09" etc. Now you can tell logrotate to use dateext and dateformat -%Y-%m-%d, and hopefully this will trick logrotate to assume the date part was created by logrotate itself. The config then becomes something like:



          /var/log/remote/*/log 
          nocreate
          dateext
          dateformat -%Y-%m-%d
          delaycompress



          However if I were you I would not try to force logrotate to handle these logfiles which don't behave like logrotate expects. I would roll my own log expiry script, something like:



          #!/bin/sh
          DAYS=90
          TOPDIR=/var/log/remote
          cd $TOPDIR
          for i in *; do
          if ! [ -d $TOPDIR/$i ]; then
          continue
          fi
          cd $TOPDIR/$i
          find -maxdepth 1 -type f -name '????-??-??' -mtime +1 -exec gzip ;
          find -maxdepth 1 -type f -name '????-??-??.gz' -mtime +$DAYS -delete
          done





          share|improve this answer

























          • Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

            – Mike Ingraham
            Jan 10 at 14:43



















          0














          For me what you are asking is pretty normal. Let's assume you have three files file1.log, file2.log and file3.log inside a folder in /var/log/remote/ and you want to rotate them daily and keep the last 10 compressed. You can do it as follows:



          1. Create a file in /etc/logrotate.d/myfiles.

          2. Paste the following content in it.


            /var/log/remote/*.log


            rotate 10

            daily

            sharedscripts

            missingok

            compress




          3. You can test it running logrotate in debugging mode.


            logrotate -d /etc/logrotate.d/myfiles




          4. If you actually want to execute it now.


            logrotate -f /etc/logrotate.d/myfiles




          I hope this helps.






          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493299%2flogrotate-continues-to-rotate-compress-already-rotated-logs%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You basically want to rotate log files that end with a digit in the specified directory, so the log matching becomes:



            /var/log/remote/*/*[0-9]


            A problem you're running into is that logrotate probably has the create option set as default, meaning that after a logfile is rotated (meaning it is renamed and maybe compressed), a new logfile with the original name is created. This can be prevented by using the nocreate option.



            However, you biggest problem is that your logfiles don't have a fixed name. logrotate keeps X versions of logfiles that have the same name; as the name changes every day, logrotate keeps one version of each day, so nothing ever gets removed.



            It might work if you could convince whatever is creating these logfiles to have some prefix like "log-" so that the names become "log-2019-01-09" etc. Now you can tell logrotate to use dateext and dateformat -%Y-%m-%d, and hopefully this will trick logrotate to assume the date part was created by logrotate itself. The config then becomes something like:



            /var/log/remote/*/log 
            nocreate
            dateext
            dateformat -%Y-%m-%d
            delaycompress



            However if I were you I would not try to force logrotate to handle these logfiles which don't behave like logrotate expects. I would roll my own log expiry script, something like:



            #!/bin/sh
            DAYS=90
            TOPDIR=/var/log/remote
            cd $TOPDIR
            for i in *; do
            if ! [ -d $TOPDIR/$i ]; then
            continue
            fi
            cd $TOPDIR/$i
            find -maxdepth 1 -type f -name '????-??-??' -mtime +1 -exec gzip ;
            find -maxdepth 1 -type f -name '????-??-??.gz' -mtime +$DAYS -delete
            done





            share|improve this answer

























            • Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

              – Mike Ingraham
              Jan 10 at 14:43
















            1














            You basically want to rotate log files that end with a digit in the specified directory, so the log matching becomes:



            /var/log/remote/*/*[0-9]


            A problem you're running into is that logrotate probably has the create option set as default, meaning that after a logfile is rotated (meaning it is renamed and maybe compressed), a new logfile with the original name is created. This can be prevented by using the nocreate option.



            However, you biggest problem is that your logfiles don't have a fixed name. logrotate keeps X versions of logfiles that have the same name; as the name changes every day, logrotate keeps one version of each day, so nothing ever gets removed.



            It might work if you could convince whatever is creating these logfiles to have some prefix like "log-" so that the names become "log-2019-01-09" etc. Now you can tell logrotate to use dateext and dateformat -%Y-%m-%d, and hopefully this will trick logrotate to assume the date part was created by logrotate itself. The config then becomes something like:



            /var/log/remote/*/log 
            nocreate
            dateext
            dateformat -%Y-%m-%d
            delaycompress



            However if I were you I would not try to force logrotate to handle these logfiles which don't behave like logrotate expects. I would roll my own log expiry script, something like:



            #!/bin/sh
            DAYS=90
            TOPDIR=/var/log/remote
            cd $TOPDIR
            for i in *; do
            if ! [ -d $TOPDIR/$i ]; then
            continue
            fi
            cd $TOPDIR/$i
            find -maxdepth 1 -type f -name '????-??-??' -mtime +1 -exec gzip ;
            find -maxdepth 1 -type f -name '????-??-??.gz' -mtime +$DAYS -delete
            done





            share|improve this answer

























            • Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

              – Mike Ingraham
              Jan 10 at 14:43














            1












            1








            1







            You basically want to rotate log files that end with a digit in the specified directory, so the log matching becomes:



            /var/log/remote/*/*[0-9]


            A problem you're running into is that logrotate probably has the create option set as default, meaning that after a logfile is rotated (meaning it is renamed and maybe compressed), a new logfile with the original name is created. This can be prevented by using the nocreate option.



            However, you biggest problem is that your logfiles don't have a fixed name. logrotate keeps X versions of logfiles that have the same name; as the name changes every day, logrotate keeps one version of each day, so nothing ever gets removed.



            It might work if you could convince whatever is creating these logfiles to have some prefix like "log-" so that the names become "log-2019-01-09" etc. Now you can tell logrotate to use dateext and dateformat -%Y-%m-%d, and hopefully this will trick logrotate to assume the date part was created by logrotate itself. The config then becomes something like:



            /var/log/remote/*/log 
            nocreate
            dateext
            dateformat -%Y-%m-%d
            delaycompress



            However if I were you I would not try to force logrotate to handle these logfiles which don't behave like logrotate expects. I would roll my own log expiry script, something like:



            #!/bin/sh
            DAYS=90
            TOPDIR=/var/log/remote
            cd $TOPDIR
            for i in *; do
            if ! [ -d $TOPDIR/$i ]; then
            continue
            fi
            cd $TOPDIR/$i
            find -maxdepth 1 -type f -name '????-??-??' -mtime +1 -exec gzip ;
            find -maxdepth 1 -type f -name '????-??-??.gz' -mtime +$DAYS -delete
            done





            share|improve this answer















            You basically want to rotate log files that end with a digit in the specified directory, so the log matching becomes:



            /var/log/remote/*/*[0-9]


            A problem you're running into is that logrotate probably has the create option set as default, meaning that after a logfile is rotated (meaning it is renamed and maybe compressed), a new logfile with the original name is created. This can be prevented by using the nocreate option.



            However, you biggest problem is that your logfiles don't have a fixed name. logrotate keeps X versions of logfiles that have the same name; as the name changes every day, logrotate keeps one version of each day, so nothing ever gets removed.



            It might work if you could convince whatever is creating these logfiles to have some prefix like "log-" so that the names become "log-2019-01-09" etc. Now you can tell logrotate to use dateext and dateformat -%Y-%m-%d, and hopefully this will trick logrotate to assume the date part was created by logrotate itself. The config then becomes something like:



            /var/log/remote/*/log 
            nocreate
            dateext
            dateformat -%Y-%m-%d
            delaycompress



            However if I were you I would not try to force logrotate to handle these logfiles which don't behave like logrotate expects. I would roll my own log expiry script, something like:



            #!/bin/sh
            DAYS=90
            TOPDIR=/var/log/remote
            cd $TOPDIR
            for i in *; do
            if ! [ -d $TOPDIR/$i ]; then
            continue
            fi
            cd $TOPDIR/$i
            find -maxdepth 1 -type f -name '????-??-??' -mtime +1 -exec gzip ;
            find -maxdepth 1 -type f -name '????-??-??.gz' -mtime +$DAYS -delete
            done






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 9 at 12:17

























            answered Jan 9 at 9:04









            wurtelwurtel

            10.3k11526




            10.3k11526












            • Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

              – Mike Ingraham
              Jan 10 at 14:43


















            • Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

              – Mike Ingraham
              Jan 10 at 14:43

















            Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

            – Mike Ingraham
            Jan 10 at 14:43






            Bingo-nocreate! Wondered about the changing file names. I'd plagiarized my setup ;-) Thought I'd done something wrong in applying it. Example contained the means to direct the syslog to unique directories for each source and to name the log files on a daily basis. It then have a section on setting up logrotate to manage those. I think the original example never really actually worked. So part of my problem was trying to debug a setup that never worked. Thanks! I think I'll got with your suggested script to purge old logs as that's the most straightforward.

            – Mike Ingraham
            Jan 10 at 14:43














            0














            For me what you are asking is pretty normal. Let's assume you have three files file1.log, file2.log and file3.log inside a folder in /var/log/remote/ and you want to rotate them daily and keep the last 10 compressed. You can do it as follows:



            1. Create a file in /etc/logrotate.d/myfiles.

            2. Paste the following content in it.


              /var/log/remote/*.log


              rotate 10

              daily

              sharedscripts

              missingok

              compress




            3. You can test it running logrotate in debugging mode.


              logrotate -d /etc/logrotate.d/myfiles




            4. If you actually want to execute it now.


              logrotate -f /etc/logrotate.d/myfiles




            I hope this helps.






            share|improve this answer



























              0














              For me what you are asking is pretty normal. Let's assume you have three files file1.log, file2.log and file3.log inside a folder in /var/log/remote/ and you want to rotate them daily and keep the last 10 compressed. You can do it as follows:



              1. Create a file in /etc/logrotate.d/myfiles.

              2. Paste the following content in it.


                /var/log/remote/*.log


                rotate 10

                daily

                sharedscripts

                missingok

                compress




              3. You can test it running logrotate in debugging mode.


                logrotate -d /etc/logrotate.d/myfiles




              4. If you actually want to execute it now.


                logrotate -f /etc/logrotate.d/myfiles




              I hope this helps.






              share|improve this answer

























                0












                0








                0







                For me what you are asking is pretty normal. Let's assume you have three files file1.log, file2.log and file3.log inside a folder in /var/log/remote/ and you want to rotate them daily and keep the last 10 compressed. You can do it as follows:



                1. Create a file in /etc/logrotate.d/myfiles.

                2. Paste the following content in it.


                  /var/log/remote/*.log


                  rotate 10

                  daily

                  sharedscripts

                  missingok

                  compress




                3. You can test it running logrotate in debugging mode.


                  logrotate -d /etc/logrotate.d/myfiles




                4. If you actually want to execute it now.


                  logrotate -f /etc/logrotate.d/myfiles




                I hope this helps.






                share|improve this answer













                For me what you are asking is pretty normal. Let's assume you have three files file1.log, file2.log and file3.log inside a folder in /var/log/remote/ and you want to rotate them daily and keep the last 10 compressed. You can do it as follows:



                1. Create a file in /etc/logrotate.d/myfiles.

                2. Paste the following content in it.


                  /var/log/remote/*.log


                  rotate 10

                  daily

                  sharedscripts

                  missingok

                  compress




                3. You can test it running logrotate in debugging mode.


                  logrotate -d /etc/logrotate.d/myfiles




                4. If you actually want to execute it now.


                  logrotate -f /etc/logrotate.d/myfiles




                I hope this helps.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 8 at 19:01









                Manuel FlorianManuel Florian

                364




                364



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493299%2flogrotate-continues-to-rotate-compress-already-rotated-logs%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)