| saveout - Save a programm's output to dynamically named files |
saveout - Save a programm's output to dynamically named files
saveout OPTIONS [--] COMMAND [ARGS]
Run COMMAND and redirect its STDOUT, and/or STDERR, and/or other file descriptors, line-by-line, to dynamically named files. Always append to output files. Useful for eg. to save logs of a long running command (service) in separate files per day.
You can set flush rules (see below) for each output (STDOUT, STDERR, specific FD...). A particular file is always flushed when the filename of the given output changes (as the old file is closed). Output is written per complete lines, so don't expect long data not delimited by linefeed to appear chunk-by-chunk, even with bytes- or time-based flushing. Only linefeed is taken as line terminator, not even a sole carriage-return.
Equivalent to --fd-1 TEMPLATE.
Equivalent to --fd-2 TEMPLATE.
Write COMMAND's output on the Nth file descriptor (STDOUT, STDERR, ...) to a file of which path and name is constructed according to TEMPLATE. TEMPLATE may contain the following macros:
Support all strftime(3) macros, eg. %c, %s, %F, %T, ...
The PID of the process running COMMAND.
The line's substring at the given POS position and LEN length, or to the end of line (excluding the terminating linefeed char) if :LEN is not given. Both POS and LEN can be negative; see perldoc -f substr for details.
Beware of potential unwanted path traversal!
Make sure that the resulting file path does not go outsite of the directory you intended to write,
by eg. output, controlled by untrusted party, containing something like ../../../etc/.
Not implemented.
Not implemented.
Flush output files after LINES number of lines. Flush per each line if LINES is not given (default LINES is 1). By default, leaves flushing to the underlaying IO layer, which usually buffers 4-8k blocks. If you want to set different flushing rules on different outputs, othen than buffered-IO or other than the default given by -L option, override by -Lo, -Le, and/or -Ln. See below.
Equivalent to -Ln 1=LINES.
Equivalent to -Ln 2=LINES.
Set file descriptor FD's output to be flushed by each LINES lines. Default LINES is 1.
Similar to the --flush-lines option group, except flush after at least BYTES bytes are written to the selected outputs. Maybe does not make sense to set more than the buffered-IO block size.
Similar to the --flush-lines and --flush-bytes option groups, except flush after at least SEC seconds passed since last write to the selected outputs.
If can not write to the output file, or can not even open it, print the failed line of text to its own STDERR, then depending on the ACTION:
Terminate COMMAND by SIGTERM, then continue running, but will also exit soon as COMMAND probably terminates upon the signal. This is the default.
Send SIGPIPE to COMMAND, then continue running. COMMAND may recover from the error condition itself.
Just ignore.
See the above comment on %[substr] template macro.
savelog(8), logto(1), stdsyslog(1), loggerexec(1), redirexec(1), logger(1), stdfilt(1)
| saveout - Save a programm's output to dynamically named files |