0

Our application is using a very busy MySQL database with lots of reads, sometimes I don't want to look at the MySQL log files, I just want the output from mytop for the last 5 minutes. How do I write the output from mytop to a file?

Given that "mytop -u root --prompt > database.load" does not work?

Update I was using --prompt instead of -p with the -b flag, which kept on throwing an exception. So the solution would have been to do mytop -u root -p password > database.load

MrD
  • 235
  • 5
  • 11

2 Answers2

2

You could use the -b option from mytop. From the manual page:

   -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.
Sven
  • 98,649
  • 14
  • 180
  • 226
  • hi, the batchmode not showing qps now, what i have to do so this will show queries per second in batch mode also, i want to log this in a file, thank you – ɹɐqʞɐ zoɹǝɟ Feb 05 '16 at 12:59
1

like this:

mytop -b > /tmp/mytop.log

Chrissav
  • 11
  • 2