Skip to content

Instantly share code, notes, and snippets.

@0x00dec0de
Created May 12, 2016 22:35
Show Gist options
  • Save 0x00dec0de/3a9e7e570d975465c984f36614f11cd1 to your computer and use it in GitHub Desktop.
Save 0x00dec0de/3a9e7e570d975465c984f36614f11cd1 to your computer and use it in GitHub Desktop.
#!/bin/bash
MYSQL=`which mysql`
MYSQLUSER=root
MYSQLPASSWD=`grep ^mysql= /usr/local/directadmin/scripts/setup.txt|cut -d'=' -f2`
MYSQLHOST=localhost
DST=/var/spool/mysqlsfp
DST=$DST/`date +%Y-%m-%d`
mkdir -p $DST
cd `dirname $0`
FN=`date +%Y.%m.%d-%k:%M:%S`
OP="select concat('========================================== ',now(),' =============================================') as date;show full processlist;"
SLOP="select sleep(10);"
LC_MESSAGES=ru_RU.UTF-8
LC_COLLATE=ru_RU.UTF-8
LANG=ru_RU.UTF-8
export LC_MESSAGES LC_COLLATE LANG
$MYSQL -u${MYSQLUSER} -p${MYSQLPASSWD} -h${MYSQLHOST} -NBe "${OP}${SLOP}${OP}${SLOP}${OP}${SLOP}${OP}${SLOP}${OP}${SLOP}${OP}" 2>&1| gzip -c > $DST/${FN}.gz
find $DST -mtime +30 -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment