/etc/logrotate.d/sample-log
/path/to/logs/*.txt {
nocompress
copytruncate
dateext
rotate 15
size 250K
}
This will run on a cron. To manually run it you can do:
logrotate /etc/logrotate.d/sample-log
More information:
https://nivethan.dev/devlog/logrotate.html