mytop의 출력을 파일에 쓰는 방법

mytop의 출력을 파일에 쓰는 방법

우리 애플리케이션은 읽기가 많은 매우 바쁜 MySQL 데이터베이스를 사용하고 있습니다. 때로는 MySQL 로그 파일을 보고 싶지 않고 마지막 5분 동안 mytop의 출력을 원합니다. mytop의 출력을 파일에 어떻게 쓰나요?

"mytop -u root --prompt > Database.load"가 작동하지 않는다면?

업데이트 -b 플래그와 함께 -p 대신 --prompt를 사용했는데 계속해서 예외가 발생했습니다. 그래서 해결책은 다음과 같았을 것입니다mytop -u root -p password > database.load

답변1

-bmytop의 옵션을 사용할 수 있습니다 . 매뉴얼 페이지에서:

   -b or --batch or --batchmode
       In batch mode, mytop runs only once, does not clear the screen, and places no limit on the number of lines it will
       print. This is suitable for running periodically (perhaps from cron) to capture the information into a file for later
       viewing. You might use batch mode in a CGI script to occasionally display your MySQL server status on the web.

       Default: unset.

답변2

이와 같이:

mytop -b > /tmp/mytop.log

관련 정보