.sh批处理保存terminal中输出的log信息

在ternimal下运行批处理程序(.sh)时想把屏幕中打印的信息保存下来方便与后期调试修改。
只需要在你的批处理后面加 >test.log 2>&1 &,如下

./name.sh >test.log 2>&1

屏幕打印的信息就被保存在了test.log中。此时屏幕还在显示运行中输出并且把输出的内容保存在test.log中。如果不想让屏幕显示程序运行中的输出,而仅仅把输出内容保存在log中,则继续在末尾添加 (空格)&,如下

./name.sh >test.log 2>&1 &

猜你喜欢

转载自blog.csdn.net/qq_35250841/article/details/105732895