DirectAdmin Knowledge Base and Support

DirectAdmin is a web panel for a simple administration of both virtual and dedicated servers. DirectAdmin is faster, safe and more powerful than any other CP. And we know how to customize and support it.

How to dump mysql proccess list with cron

| 14:38:20 04.07.2014

Should you need to dump mysql proccess list with cron here you can find a nice script to do it. Please feel free to use it on your server, if default mysql slow queries logging is not enough for your purposes.

#!/bin/bash
#
# Plugins-DA.NET (support@plugins-da.net)
# Written by Alex S Grebenschikov # Version: 0.3, 2014-07-04 # ############################################################## # RUN THIS SCRIPT MANUALY OR WITH CRON # */5 * * * * root /root/dump_mysql_processlist.sh # CONSIDER TO SAVE IN /root/ OR ANY OTHER DIRECTORY ############################################################## ############################################################## # You may change SAVE_TO_DIR to any other value # which suits you the best ############################################################## SAVE_TO_DIR="/root/mysql_proclists/"; ############################################################## DIR="$SAVE_TO_DIR/$(date +%d)"; [ -d "$DIR" ] || mkdir -p $DIR; FILE="${DIR}/$(date +%H%M).dump"; MYSQLADMIN=""; if [ -x "/usr/local/mysql/bin/mysqladmin" ]; then MYSQLADMIN="/usr/local/mysql/bin/mysqladmin"; elif [ -x "/usr/local/bin/mysqladmin" ]; then MYSQLADMIN="/usr/local/bin/mysqladmin"; elif [ -x "/usr/bin/mysqladmin" ]; then MYSQLADMIN="/usr/bin/mysqladmin"; else echo "ERROR! mysqladmin was not found on the server!" exit 1; fi; $MYSQLADMIN \ --defaults-extra-file=/usr/local/directadmin/conf/my.cnf \ processlist \ --verbose=true >${FILE} 2>&1 exit 0;

Save it to /root/dump_mysql_processlist.sh and chmod it 700. Set a cron task to run it every 5 minute:

*/5 *  *  *  * root /root/dump_mysql_processlist.sh

Please consider to have /usr/local/directadmin/conf/my.cnf with such a content (example):

[client]
user=da_admin
password=SECRET_PASS

Where SECRET_PASS should be replaced with a valid password taken from /usr/local/directadmin/conf/mysql.conf

Have fun with dumps which are stored for 30 days before they get overwritten.

About Us
We are a team of professionals, and specialize in installation, configuring and managing of remote virtual and dedicated servers powered by Linux/Unix-like OS with DirectAdmin. We support various sets of software, including web-servers Apache, Nginx; internet domain name servers Bind, PowerDNS; mail-servers with POP3, IMAP and SMTP, FTP-servers, etc. After years of working through the most complex server challenges our team has gathered valuable experience and universal solutions suitable for everyday tasks. We are here to lend you a helping hand and take care of your servers in order to let you have enough time to do more of what you love.




All of the information and data on this site is for informational purposes only and is provided for the convenience of the user.
Powered by: Amiro.CMS - Free edition