Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m1kc/autocleaner
A program that deletes old files with configurable storage period. It uses `find` internally, and is capable of handling millions of files very quickly.
https://github.com/m1kc/autocleaner
cleaner cleanup housekeeping ruby system systemd systemd-service utility
Last synced: about 1 month ago
JSON representation
A program that deletes old files with configurable storage period. It uses `find` internally, and is capable of handling millions of files very quickly.
- Host: GitHub
- URL: https://github.com/m1kc/autocleaner
- Owner: m1kc
- Created: 2021-11-02T15:58:59.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T09:44:12.000Z (over 2 years ago)
- Last Synced: 2024-11-06T22:44:03.348Z (3 months ago)
- Topics: cleaner, cleanup, housekeeping, ruby, system, systemd, systemd-service, utility
- Language: Ruby
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# autocleaner
A program that deletes your files with configurable storage period.
It uses `find` internally, and therefore it's very fast (and that's
important when you're dealing with millions of files).:wrench: Quality: **beta**
:cityscape: Used in production since **Nov 2021**## Requirements
* Ruby 2.0...2.7
* `find` in PATH## Install
```sh
cd /opt
sudo git clone https://github.com/m1kc/autocleaner.git
cd autocleaner
sudo make install
sudo nano /etc/autocleaner/config.rb # edit config as you see fit
sudo make activate # this will enable and start systemd timer
```## Usage
Edit `/etc/autocleaner/config.rb` and define which folders you want to
be auto-cleaned and how long to store files inside them.**Added in v1.1.0:** you can also set :glob parameter to limit the scope
to files matching the given pattern, like `*.log`, `temp-*`,
or `*` (all files, default). Note that unlike in bash, `*` matches
dotfiles as well.```ruby
module Config
FOLDERS = [
# Define your folders here.
{ :folder => "/tmp", :days => 900 },
{ :folder => "/var/log/myservice", :days => 30 },
{ :folder => "/var/log/myotherservice", :days => 60, :glob => "*.txt" },
]
end
```Days are counted from file's _modification time_ (mtime).
**Note:** you **can** define overlapping folders. In such cases, **smallest**
storage period wins. In other words, if a file is to be kept by one policy
and to be deleted by another, it will be deleted.## Known caveats
* On Ruby 2.0.0p648, the following warning appears: `/etc/autocleaner/config.rb:1:in '': Use RbConfig instead of obsolete and deprecated Config`. This is harmless and should be ignored.
## Planned features
(for requests, create an issue or drop me a note at [email protected])
* `--dry-run` flag
* `--validate-config` flag
* Deletion of empty folders