Sign inSign up

floholz/goclean

By floholz

β€’Updated over 2 years ago

Simple tool to clean up directories on a schedule

Image
0

400

floholz/goclean repository overview

⁠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!

Tag summary

Content type

Image

Digest

sha256:01be9f28b…

Size

291.6 MB

Last updated

over 2 years ago

docker pull floholz/goclean