
screen -d -m script.sh 2>&1 | tee logfile.log
但这显然不起作用.引用在这里没有帮助.我唯一的想法是创建一个包装器脚本,它将执行此重定向,然后直接调用它,如:
screen -d -m wrapper_script.sh
还有其他想法吗?谢谢.
解决方法 你可以让屏幕运行一个bash shell,然后运行你的脚本.我刚试过这个:
screen -d -m bash -c 'vmstat 5 3 2>&1 | tee logfile.log'
这给了我这个:
kenny@t520:~$cat logfile.log procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy ID wa 1 0 0 5864764 103072 884512 0 0 66 36 1236 1818 17 6 77 0 0 0 0 5864252 103072 884512 0 0 0 0 311 574 1 1 98 0 1 0 0 5861532 103080 884512 0 0 0 4 1244 2302 4 2 94 0
所以这也应该有效:
screen -d -m bash -c 'script.sh 2>&1 | tee logfile.log'总结
以上是内存溢出为你收集整理的linux – 启动分离的屏幕会话全部内容,希望文章能够帮你解决linux – 启动分离的屏幕会话所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)