如何将 shell 会话的所有控制台输出发送到日志文件

发布于 2024-11-30 19:30:38 字数 120 浏览 6 评论 0原文

我不确定这是否可能,但在登录后自动将所有控制台输出(stderr 和 stdout)自动发送到日志文件会非常方便。我希望它在每次登录和发送时创建一个唯一的文件所有这些输出到我的日志目录。预先感谢您提供任何帮助我进行设置的想法。

I am not sure if this is possible but it would be terribly handy to automatically tee all console output (stderr and stdout) to a log file starting after logging in. I would want it to create a unique file each time I log in and tee all that output to my logs directory. Thanks in advance for any ideas to help me set this up.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝天 2024-12-07 19:30:38

据我所知,唯一接近您想要的实用程序是 script 命令这会生成您的会话的完整记录。

要为所有登录自动执行此操作,您可能需要创建一个包装脚本并将其设置为默认 shell。

网络上的一场快速小冲突导致了这个脚本:http://snipt.net /d1s4st3r/script-that-acts-as-a-login-shell-replacement-to-log-everything-an-user-does/

我没有使用过它,但是在乍一看,它看起来就像罐头上说的那样。

The only utility I know of that comes close to what you want is the script command which makes a full transcript of your session.

To do this automatically for all your logins, you'll probably need to create a wrapper script and set that as your default shell.

A quick skirmish on the web resulted in this script: http://snipt.net/d1s4st3r/script-that-acts-as-a-login-shell-replacement-to-log-everything-an-user-does/

I haven't used it, but at a glance it looks like it does as it says on the can.

好久不见√ 2024-12-07 19:30:38

这是描述命令“脚本”的站点的链接,该命令采用日志文件的参数来创建。将其放在 .login 文件中将导致每次登录时都会创建日志。使用日期和时间生成日志文件名将为每个会话创建单独的日志。输入 Ctrl-D 将结束脚本会话我还没有对此进行测试,但我很确定这就是所述问题的解决方案。

http://lxtipsandtricks.blogspot.com/2009 /03/how-to-capture-unix-console-screen.html

Here is a link to a site describing the command "script" which takes a paramater of the log file to create. Placing this in the .login file will cause the log to be created everytime you login. Using the Date and Time to generate the log file name will create seperate logs per session. Entering Ctrl-D will end the script session I have not tested this yet but I am pretty sure this is the solution to the problem as stated.

http://lxtipsandtricks.blogspot.com/2009/03/how-to-capture-unix-console-screen.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文