Goclean is a tool written in golang, to clean up specified directories on a schedule.
## 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
Configuring goclean
is done with environment variables.
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"
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.β
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.β
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Copyright Β© 2024 floholz.
This project is MIT licensed.
Give a β if this project helped you!