1
2
3
4
5
#!/bin/sh
/ usr / local / mysql / bin / mysql  - - default - character - set = utf8  - h127. 0.0 . 1  - u root  - p123456  - "show master status"  / root / master_binlog
binlog_pos = `grep mysql - bin  / root / master_binlog | awk  '{print $1' }`
echo $binlog_pos
/ usr / local / mysql / bin / mysql  - h127. 0.0 . 1  - - default - character - set = utf8  - u root  - p123456  - "purge binary logs to '$binlog_pos'"