File rollover

by George Lester

Version 1 (June 27, 2019)

Download (80 downloads)

(it's logrotate) Writes a payload to file. If the file is then bigger than the give limit, renames it with a timestamp and starts a new (identically named) file.

Useful for logging, or writing files that should be uploaded/deleted periodically.

Payload must be a three-element array. First is the full path to the desired file, second is the contents you wish to write, third is the file size (in bytes) that is required before rolling the file.