Hi phillipe,
This is easy to do with logrotate since you can use wildcards to define your paths and files. I placed a logrotate config file in /etc/logrotate.d/
called storagenode
. It is a plain text file. My logrotate config file is as follows. Don’t include comments in your config file (there is an uncommented version below).
/mnt/logs-usb/storj*/storagenode*.log {
#the wildcard (*) characters tell logrotate to look in any subfolder that
#begins with storj, and rotate any log that starts with storagenode
#and has a .log extension
su user group #run as specific user and group, this may not be necessary for you
weekly #rotates logs weekly
maxsize 200M #rotate logs if log file is greater than 200 MB even if it has been less than a week
rotate 52 #keep 52 previous log files
dateext #append date to rotated log file extensions
dateformat -%Y%m%d #use this date format for rotated logs
compress #compress rotated logs
delaycompress #leave the most recent rotate log uncompressed until the next cycle
missingok #do not error out if log file is missing
notifempty #do not rotate empty log files
copytruncate #copies rotated log and truncates original
}
Uncommented version
/mnt/logs-usb/storj*/storagenode*.log {
su user group
weekly
maxsize 200M
rotate 52
dateext
dateformat -%Y%m%d
compress
delaycompress
missingok
notifempty
copytruncate
}
You can get more information about different log rotate options here
https://www.man7.org/linux/man-pages/man8/logrotate.8.html