0

I am running following script to monitor some processes and store the output in html file. But on running, it gives the error top: failed tty get. Here is the script:

var=4
while [ $var -ge 0 ]
do
`echo q | htop --p=2164 | aha --black --line-fix >> htop2.html`
#$cmd
sleep 1
var=$(($var-1))
done

Please guide me to solve this error!

1
  • Are you running the script from a cron job? Is that the exact script that generated that error? Commented Oct 9, 2022 at 12:37

1 Answer 1

-1

It seems to me, that you don't have htop installed. What's the output of which htop and alias? Most likely the command htop points to top on your system. Contrary to htop, top cannot be used in non-interactive environments/scripts. Try to install the 'real' htop.

1
  • The error looks like it's from top, not htop, but wouldn't top have complained about the --p option? Also notice the strange command substitution in the code. I don't think we're seeing the code that generated that exact error. Commented Oct 9, 2022 at 12:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.