Skip to content

Instantly share code, notes, and snippets.

@ananthakumaran
Created September 24, 2012 10:02
Show Gist options
  • Save ananthakumaran/3775257 to your computer and use it in GitHub Desktop.
Save ananthakumaran/3775257 to your computer and use it in GitHub Desktop.
#!/bin/bash
args=$@
log_off() {
mysql $args <<<"SET GLOBAL general_log = 'OFF'"
echo 'set general_log off'
}
trap log_off SIGINT
log_file=`mysql $args <<<"SHOW VARIABLES LIKE 'general_log_file'" | sed -n 2p | cut -f 2`
mysql $args <<<"SET GLOBAL general_log = 'ON'"
echo 'set general_log on'
tail -f $log_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment