See MySQL processes each second

A few days ago, i needed to analyze the MySQL processes of a server, as it was very important that nothing heavy was running. So here i share a few ways to check MySQL processes x second(s), i came across.

The mysqladmin way

In newer versions of mysql/mysqladmin you can use the -i flag for interval, which will just call the same command x second, and send it to standard output.

Example
$ mysqladmin -uroot -ppassword -i 1 processlist

The watch command

Watch will create a fullscreen window, with details about what command you have executed, time and date, and seconds between screen is updating (-n). Under these details watch will provide the output of the executed command, updating x seconds.

Example
$ watch -n 1 mysqladmin --user=root --password=password processlist

The bash while loop

If you want the output as standard output, which in some cases can be more handy, and if you like the good old way like me, then it can simply be done with a while loop in bash. Set a sleep x after the command you want to have executed, so you still have a chance to read what hits the command-line.

Example
$ while [ true ]; do mysql -uroot -ppassword -e'show full processlist;'; sleep 1; done

Or how i simply would do from the command-line:

$ while true        
while> do
while> mysql -uroot -ppassword -e 'show full processlist;'
while> sleep 1
while> done