Crates.io | frots |
lib.rs | frots |
version | |
source | src |
created_at | 2024-12-01 01:39:47.799022 |
updated_at | 2024-12-03 14:17:12.348355 |
description | File rotation from standard input |
homepage | |
repository | https://github.com/e-dant/frots |
max_upload_size | |
id | 1467113 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
frots
: File rotation from standard inputThe only file rotation tool I'm aware of that actually handles stdout.
logrotate
(which you really ought to use if you can) happens to use rename()
under the hood to move the primary logfile into rotation, which confuses programs
already writing to it (they will now be writing to the rotated file, which is weird).
frots
was primarily made to solve that problem.
Reads standard input into the specified file
(-f
) until:
If file
grows to reach or exceed the limit
(-s
), then:
file
with the disk.R
..1 (where R
is -r
, --num-rotate
),
rename file.N
to file.N+1
if N + 1 < R
. (I.e., rotate the files.)file
file.1
Example usage:
# Two files (one active, one rotated) of 1GB each; Verbose output along with "tee"ing
some-prog | frots -f /var/log/prog/a.log -s 1G -r 2 --tee -v
Notes:
rename()
, not copy-and-move.fsync()
.Usage: frots [OPTIONS] --file-path <FILE_PATH> --file-sz-lim <FILE_SZ_LIM>
Options:
-f, --file-path <FILE_PATH>
The name of the file to write to
-s, --file-sz-lim <FILE_SZ_LIM>
The size limit of the file in a byte-unit format (1KB, 3M, 4G, etc.) before rotation
-r, --num-rotate <NUM_ROTATE>
The number of files to rotate through (see '--help' for more), must be >= 1
[default: 1]
--b-is-bits
If "b" means bytes or bits for the `file_sz_lim`, i.e., if 1Kb = 8192b or 1024B
--tee
Whether to "tee" stdin to stdout as well as to `file` (just like `tee(1)`)
-v, --verbose
Verbose output, as-if by setting `RUST_LOG=info` in the environment
-h, --help
Print help (see a summary with '-h')