how to customize `show processlist` in mysql?

前端 未结 6 1077
孤城傲影
孤城傲影 2021-01-29 18:11

I want to order by Time,but seems no way to do that ?

mysql> show processlist;
+--------+-------------+--------------------+------+---------+--------+--------         


        
6条回答
  •  不知归路
    2021-01-29 18:30

    You can just capture the output and pass it through a filter, something like:

    mysql show processlist
        | grep -v '^\+\-\-'
        | grep -v '^| Id'
        | sort -n -k12
    

    The two greps strip out the header and trailer lines (others may be needed if there are other lines not containing useful information) and the sort is done based on the numeric field number 12 (I think that's right).

    This one works for your immediate output:

    mysql show processlist
        | grep -v '^\+\-\-'
        | grep -v '^| Id'
        | grep -v  '^[0-9][0-9]* rows in set '
        | grep -v '^ '
        | sort -n -k12
    

提交回复
热议问题