You are not logged in.
I want to create a large log file for everything printed to stdout and stderr (separately, preferably) that is owned (might be the wrong terminology) by my user or the root. The idea is that I could run a program from the terminal like normal, and everything it printed would also be written to this log file. Is there a way to do this? It seems like something that a lot of people would have a use for.
Last edited by pixie (2024-11-01 01:17:11)
Offline
The simplest / manual way would be to use tee:
some-command-here 2>&1 | tee -a /path/to/logfile
If there were specific commands you wanted to log, this could work well. But for every command typed directly in an interactive shell, you'd be better off using the `script' tool perhaps launched from your shellrc.
As for anything outside of an interactive shell, this would be highly impractical and likely be a very bad idea. Most of that is logged somewhere already (mostly the journal nowadays).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You want all output written to the terminal but stderr and stdout also logged to separate files so are you asking for something like?
some-command-here 2> >(tee stderr.log) > >(tee stdout.log)
Offline
Offline
This is exactly what I had in mind, thank you!
Offline
\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline