我们的应用程序正在使用一个非常繁忙的MySQL数据库,有很多的读取,有时我不想看MySQL日志文件,我只想在最后5分钟从mytop的输出。 如何将mytop的输出写入文件?
鉴于“mytop -u root –prompt> database.load”不起作用?
更新我使用–prompt而不是-p标志,它保持抛出一个exception。 所以解决办法是做mytop -u root -p password > database.load
你可以使用mytop的-b选项。 从手册页:
-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.
喜欢这个:
mytop -b> /tmp/mytop.log