Is it possible JUST to delete the log files in a directory by using logrotate w/o actually rotating them? We have an app that generates logs in the following format: app.log.DD_MM_YYYY. I am unsuccessful with logrotate having the following config:

/opt/log/app/app.log.* {
         rotate 0

Can log rotate do this or should I just write a script and place it within cron?

Best, -Iulian

  • If you dont need those logs why not disable logging feature on your app?
    – Deeh
    Jul 31, 2015 at 18:30
  • 3
    I am sorry but I can't count that as an answer Deeh. To feed your curiosity, we need those logs for different operations like debugging, we just don't want to keep them there to rot.
    – Iulian
    Aug 4, 2015 at 10:00

2 Answers 2


In that case you may want to use postrotate. In the example below postrotate will delete files that are older that 1 day after logs been rotated, feel free to modify it to fit your needs.

/opt/log/app/app.log.* {
        /usr/bin/find /opt/log/app/ -name "app.log.*" -type f -mtime +0 -exec rm {} \;

The purpose of logrotate is to keep a custom number of log files on a custom time interval. I would use cron for your task. More about what you can do with logrotate here: http://www.jamescoyle.net/cheat-sheets/676-logrotate-cheat-sheet

  • 2
    Please do not post link-only answers to prevent link rot. Instead, add the most relevant information from the link to your answer or alternatively, post the link as a comment instead of an answer. See this help center article for further information.
    – Sven
    Jul 24, 2015 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.