SQL Show Log

#!/bin/bash
# —————————————————-
#
# SQL Show Log version 1.0
# @author Raymond S. Usbal
# @usage sqlshowlog
#
# —————————————————-

### check parameter
E_NO_ARGS=65

if [ $# -eq 0 ]
then
echo “SQL Show Log version 1.0
Usage: sqlshowlog

exit $E_NO_ARGS
fi

### get latest MySQL log
for file in mysql-bin.??????*; do FLE_LATEST=$file; done;

### build start date string
START_DTE=$(date +%Y-%m-%d\ %k:$(($(date +%M) – $1)):%S)

mysqlbinlog –start-date=”$START_DTE” $FLE_LATEST \
| grep -v ‘^[#/]‘ \
| grep -v ‘SET TIMESTAMP’ \
| grep -v ‘SET @@session’ \
| grep -v ‘DELIMITER’ \
| grep -v ‘ROLLBACK’ \
| sed ‘s/\/\*!\*\///g’

### end

About Raymond

I'm a Christian web developer from the Philippines. Sometimes I write also.
This entry was posted in Bash script. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>