lcleaner is short for Log Cleaner. This deletes the log files before the storage period you set. A daemon checks and deletes log files once a day (fixed at midnight)
- Clone Repository
$ git clone https://github.com/zajann/lcleaner.git- Run
install.sh
$ cd lcleaner/scripts
$ ./install.shIf a message :# Enter the installation directory showing up after running, Enter the absolute path to the directory you want to install. And DONE !
After installation if you move <YOUR-LCLEANER-DIR, you can see 3 directories below.
bin : where binary file is located: lcleaner
etc: where configuration file is located
log: where log files are located
-
Set up
Open the
etc/lcleaner_config.ymland rewrite-
process
pidfilepath: where PID file is locatedpidfilename: name of PID file -
log
filepath: where log files are locatedfilename: name of log filelevel: level of log (0: DEBUG, 1: INFO, 2: WARN, 3: ERROR, 4: FATAL) -
targets
set up to delete
what/where/whenlog files. Multiple Settings Availablepath: where log files that you want to delete are locatedregexp: regular expression of your target log filesperiod: storage period, you can set the period to days, months, years(ex. 7d => 7 days | 6m => 6 months | 1y => 1 year)
-
-
Test
You can test if the regexp you set really match with target log files format or not before running.
# example $ ./lcleaner -t -regexp='mydaemon.log.bak.[0-9]+' -target='mydaemon.log.bak.20200113155633' $ true
-
Run
$ cd <YOUR-LCLEANER-DIR>/bin $ ./start.sh
If you want to stop, run
stop.sh