开发者

How to tee all console output of shell sessions to a log file

I a开发者_如何学Gom 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜