Code Monkey home page Code Monkey logo

goclean's Introduction

Welcome to goclean πŸ‘‹

Static Badge GitHub tag (with filter) GitHub License GitHub go.mod Go version (subdirectory of monorepo) Docker CI

Goclean is a tool written in golang, to clean up specified directories on a schedule.

Usage

## docker-compose.yml

version: "3"

services:
  goclean:
    container_name: "goclean"
    image: floholz/goclean:1
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - GO_CLEAN_PATHS="/mnt/goclean/dir1;/mnt/goclean/dir2"
      - GO_CLEAN_SCHEDULE="0 3 * * *"
      - GO_CLEAN_MAX_AGE=7d
    volumes:
      - ~/dir1:/mnt/goclean/dir1
      - ~/dir2:/mnt/goclean/dir2

Environment Variables

Configuring goclean is done with environment variables.

GO_CLEAN_PATHS (required)

This specifies what directories goclean should monitor. The paths need to be provided in a ; seperated list.

e.g.:

GO_CLEAN_PATHS="/mnt/goclean/"
GO_CLEAN_PATHS="/mnt/goclean/dir1;/mnt/goclean/dir2"
GO_CLEAN_PATHS="/mnt/goclean/dir1;/mnt/goclean/dir2;/mnt/also_goclean/dir3"

GO_CLEAN_SCHEDULE

You can specify your own schedule for clean up, by setting this environment variable. The value should be a crontab schedule string with an optional seconds parameter.

By default, the schedule is set to 0 0 * * * meaning daily at 00:00.

e.g.:

GO_CLEAN_SCHEDULE="0 3 * * *"             # β€œDaily at 03:00.”
GO_CLEAN_SCHEDULE="*/30 */10 * * * WED"   # β€œEvery 30th second after every 10th minute on Wednesday.”
GO_CLEAN_SCHEDULE="55 15 14 1 8 *"        # β€œAt 14:15:55 on 1st of August.”
GO_CLEAN_SCHEDULE="0 22 * * 1-5"          # β€œAt 22:00 on every day-of-week from Monday through Friday.”

GO_CLEAN_MAX_AGE

With this you can define the maximum age a file is allowed to have, before being deleted. This uses the duration syntax, expanded by year, month and day.

By default, the maximum age for a file is set to 7d meaning 7 days.

e.g.:

GO_CLEAN_MAX_AGE="7d"               # β€œ7 days.”
GO_CLEAN_MAX_AGE="1y6m"             # β€œ1 year and 6 months.”
GO_CLEAN_MAX_AGE="11h59m59s"        # β€œ11 hours, 59 minutes and 59 seconds.”
GO_CLEAN_MAX_AGE="2y8m7d12h5m30s"   # β€œ2 years, 8 months, 7 days, 12 hours, 5 minutes and 30 seconds.”

🀝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

πŸ“ License

Copyright Β© 2024 floholz.

This project is MIT licensed.


Show your support

Give a ⭐ if this project helped you!

goclean's People

Contributors

floholz avatar

Watchers

 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.