Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created June 28, 2017 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/ef00f85c65ee5ff93a5494abf10615fe to your computer and use it in GitHub Desktop.
Save mahemoff/ef00f85c65ee5ff93a5494abf10615fe to your computer and use it in GitHub Desktop.
Show long-running processes

The following MySQL command will show you long-running processes (exceeding 5 seconds in this case).

select * from information_schema.processlist where command <> 'sleep' and time > 5;

You can run it from console to view those happening now, or you could make a script to poll it periodically, with something like:

echo "select * from information_schema.processlist where command <> 'sleep' and time > 5;" | mysql > long-running.log

(See also https://serverfault.com/questions/416380/log-slow-queries-killed-before-completion/858093)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment