top:failed tty get 错误

运行命令,ps -ef | grep test | grep -v test | awk '{ print $2 }' | xargs top -H -p

想看test的实时状态,结果报了错,查了一下,用脚本在非交互模式下调用top就会出这个错,加上一个 -b,切换到“Batch mode”模式即可解决。

ps -ef | grep test | grep -v test | awk '{ print $2 }' | xargs top -b -H -p

原文地址:https://www.cnblogs.com/shenlinken/p/5491181.html