Rotate Logs Older Than 7 days and Delete Archive [on hold]











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









New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold 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









New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold 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









New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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









New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 4 at 13:59









Christopher

10k32847




10k32847






New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 4 at 13:28









voxsteel

1




1




New contributor




voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






voxsteel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold 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.






put on hold 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










New contributor




cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    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










    New contributor




    cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      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










      New contributor




      cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        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










        New contributor




        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        #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










        New contributor




        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited Dec 4 at 14:04









        sourcejedi

        22.3k43398




        22.3k43398






        New contributor




        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Dec 4 at 13:54









        cspoleta

        111




        111




        New contributor




        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        cspoleta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.















            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt