Coder Social home page Coder Social logo

purge-old-files's Introduction

Purge old files

Simple tool to delete old files using a set of contraints.

If --include if used, only files matching the provided glob pattern are considered. This option can be used multiple times. By default, all files are considered.

Usage

$ purge-old-files -h
usage: purge-old-files [-h] [--debug | --quiet] [--syslog] [--dry-run]
                       [--include PATTERN] [--exclude PATTERN]
                       MIN_AGE [DIRECTORY [DIRECTORY ...]]

positional arguments:
  MIN_AGE               Minimum age of files
  DIRECTORY             Directory or glob pattern to be scanned (multiple
                        directories can be provided)

optional arguments:
  -h, --help            show this help message and exit
  --debug, -D           Show debug messages
  --quiet, -q           Only show warning messages
  --syslog, -s          Send log messages to /dev/log instead of stdout
  --dry-run, -d         Show which files should be deleted
  --include PATTERN, -i PATTERN
                        Include only files matching pattern
  --exclude PATTERN, -e PATTERN
                        Exclude files matching pattern

# Purge *.log files in /logs when they are older than 3 days
$ purge-old-files --include '*.log' 3d /logs

# Delete files from /backup when they are older than 1 week
$ purge-old-files 1w /backup

# Show which files from /backup are older than 3 months
$ purge-old-files --dry-run 3M /backup

File minimum age

Supported units:

  • s: seconds
  • m: minutes
  • h: hours
  • d: days
  • w: weeks
  • M: months (30 days)
  • y: years (365 days)

Installation

$ pip install purge-old-files

Requirements

  • Python 3.x

FAQ

  • Do you know you can do this with a simple shell script using find?

    Yep. I wrote those for years. They are also painful to maintain. And error prone. Feel free to use a shell script. :)

purge-old-files's People

Contributors

pmuller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.