定期抓取慢慢查询日期及打印
0 9 * * * /data/backup/scripts/pt-query-digest.sh > /dev/null 2>&1
#!/bin/bash
perconatoolkit_home=/u01/software/mysql/percona-toolkit-2.2.14/bin
date=date "+%Y%m%d"
slowlog=/u01/mysql/mylog/MYORCL/slow.log
$perconatoolkit_home/pt-query-digest --since=24h
s
l
o
w
l
o
g
>
/
d
a
t
a
/
b
a
c
k
u
p
/
s
c
r
i
p
t
s
/
s
l
o
w
l
o
g
s
/
"
r
e
p
o
r
t
2
06.10
3
3
30
6
"
"
slowlog > /data/backup/scripts/slowlogs/"report_206.103_3306_""
slowlog>/data/backup/scripts/slowlogs/"report206.1033306""date"".log" 2>&1
if [
?
−
e
q
0
]
;
t
h
e
n
c
p
/
d
a
t
a
/
b
a
c
k
u
p
/
s
c
r
i
p
t
s
/
s
l
o
w
l
o
g
s
/
"
r
e
p
o
r
t
2
06.10
3
3
30
6
"
"
? -eq 0 ];then cp /data/backup/scripts/slowlogs/"report_206.103_3306_""
?−eq0];thencp/data/backup/scripts/slowlogs/"report206.1033306""date"".log" /opt/ptyf_bak/slowlogs/206.103 2>&1
else
exit
fi