Rotate Logs Older Than 7 days and Delete Archive [closed]











up vote
-1
down vote

favorite












I'm trying to configure logrotate to find all the log files older than 7 days from certain directories and archive them. The archived files must be deleted.



I have a structure as follows.



/var/log/myapp/subfolder1/*.log (hundreds of logs)
/var/log/myapp/subfolder2/*.log (hundreds of logs)
/var/log/myapp/subfolder3/*.log (hundreds of logs)
/var/log/myapp/subfolder4/*.log (hundreds of logs)


I know I should create a configuration file in /etc/logrotate.d/, but how can I specify the archiving of log file older than 7 days in each directory and remove the archived files?










share|improve this question















closed as unclear what you're asking by Jeff Schaller, RalfFriedl, Christopher, n.st, thrig Dec 5 at 0:12


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
    – Jeff Schaller
    Dec 4 at 16:26






  • 1




    Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
    – Christopher
    Dec 4 at 18:43















up vote
-1
down vote

favorite












I'm trying to configure logrotate to find all the log files older than 7 days from certain directories and archive them. The archived files must be deleted.



I have a structure as follows.



/var/log/myapp/subfolder1/*.log (hundreds of logs)
/var/log/myapp/subfolder2/*.log (hundreds of logs)
/var/log/myapp/subfolder3/*.log (hundreds of logs)
/var/log/myapp/subfolder4/*.log (hundreds of logs)


I know I should create a configuration file in /etc/logrotate.d/, but how can I specify the archiving of log file older than 7 days in each directory and remove the archived files?










share|improve this question















closed as unclear what you're asking by Jeff Schaller, RalfFriedl, Christopher, n.st, thrig Dec 5 at 0:12


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
    – Jeff Schaller
    Dec 4 at 16:26






  • 1




    Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
    – Christopher
    Dec 4 at 18:43













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I'm trying to configure logrotate to find all the log files older than 7 days from certain directories and archive them. The archived files must be deleted.



I have a structure as follows.



/var/log/myapp/subfolder1/*.log (hundreds of logs)
/var/log/myapp/subfolder2/*.log (hundreds of logs)
/var/log/myapp/subfolder3/*.log (hundreds of logs)
/var/log/myapp/subfolder4/*.log (hundreds of logs)


I know I should create a configuration file in /etc/logrotate.d/, but how can I specify the archiving of log file older than 7 days in each directory and remove the archived files?










share|improve this question















I'm trying to configure logrotate to find all the log files older than 7 days from certain directories and archive them. The archived files must be deleted.



I have a structure as follows.



/var/log/myapp/subfolder1/*.log (hundreds of logs)
/var/log/myapp/subfolder2/*.log (hundreds of logs)
/var/log/myapp/subfolder3/*.log (hundreds of logs)
/var/log/myapp/subfolder4/*.log (hundreds of logs)


I know I should create a configuration file in /etc/logrotate.d/, but how can I specify the archiving of log file older than 7 days in each directory and remove the archived files?







logs logrotate






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 at 13:59









Christopher

10.1k32847




10.1k32847










asked Dec 4 at 13:28









voxsteel

1




1




closed as unclear what you're asking by Jeff Schaller, RalfFriedl, Christopher, n.st, thrig Dec 5 at 0:12


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Jeff Schaller, RalfFriedl, Christopher, n.st, thrig Dec 5 at 0:12


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
    – Jeff Schaller
    Dec 4 at 16:26






  • 1




    Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
    – Christopher
    Dec 4 at 18:43














  • 1




    are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
    – Jeff Schaller
    Dec 4 at 16:26






  • 1




    Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
    – Christopher
    Dec 4 at 18:43








1




1




are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
– Jeff Schaller
Dec 4 at 16:26




are you asking logrotate to rotate these files, or just delete them? You may want to use a different tool if you just want to delete old files.
– Jeff Schaller
Dec 4 at 16:26




1




1




Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
– Christopher
Dec 4 at 18:43




Missing information: operating system name and version, name and version the of system logger, whether the logs are produced by the system logger or by the application itself, whether the application can or cannot be configured to use a system logger, etc... Also, confusion elimination, please: you first want to archive a file and then delete it? By definition, an archive is kept, not deleted. You meant rotate the logs, right, not archive?
– Christopher
Dec 4 at 18:43










1 Answer
1






active

oldest

votes

















up vote
1
down vote













#While waiting for a real answer, you may wish to play w/ the following
#following alternative outline of a solution not using "logrotate"
#Needs sanity checks, failure recovery, et cetera
find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES

#After archiving & renaming old files, $mySTREAM_ARCHIVER moves
#the originals to a holding directory, where they will be maintained
#for some time before eventually being deleted when they are too old
#Holding directory files remain there
$mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES

#Implementation, testing and cleanup are left as an exercise for the reader





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    #While waiting for a real answer, you may wish to play w/ the following
    #following alternative outline of a solution not using "logrotate"
    #Needs sanity checks, failure recovery, et cetera
    find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES

    #After archiving & renaming old files, $mySTREAM_ARCHIVER moves
    #the originals to a holding directory, where they will be maintained
    #for some time before eventually being deleted when they are too old
    #Holding directory files remain there
    $mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES

    #Implementation, testing and cleanup are left as an exercise for the reader





    share|improve this answer



























      up vote
      1
      down vote













      #While waiting for a real answer, you may wish to play w/ the following
      #following alternative outline of a solution not using "logrotate"
      #Needs sanity checks, failure recovery, et cetera
      find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES

      #After archiving & renaming old files, $mySTREAM_ARCHIVER moves
      #the originals to a holding directory, where they will be maintained
      #for some time before eventually being deleted when they are too old
      #Holding directory files remain there
      $mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES

      #Implementation, testing and cleanup are left as an exercise for the reader





      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        #While waiting for a real answer, you may wish to play w/ the following
        #following alternative outline of a solution not using "logrotate"
        #Needs sanity checks, failure recovery, et cetera
        find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES

        #After archiving & renaming old files, $mySTREAM_ARCHIVER moves
        #the originals to a holding directory, where they will be maintained
        #for some time before eventually being deleted when they are too old
        #Holding directory files remain there
        $mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES

        #Implementation, testing and cleanup are left as an exercise for the reader





        share|improve this answer














        #While waiting for a real answer, you may wish to play w/ the following
        #following alternative outline of a solution not using "logrotate"
        #Needs sanity checks, failure recovery, et cetera
        find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES

        #After archiving & renaming old files, $mySTREAM_ARCHIVER moves
        #the originals to a holding directory, where they will be maintained
        #for some time before eventually being deleted when they are too old
        #Holding directory files remain there
        $mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES

        #Implementation, testing and cleanup are left as an exercise for the reader






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 4 at 14:04









        sourcejedi

        22.5k43499




        22.5k43499










        answered Dec 4 at 13:54









        cspoleta

        111




        111















            Popular posts from this blog

            List directoties down one level, excluding some named directories and files

            list processes belonging to a network namespace

            list systemd RuntimeDirectory mounts