Tuesday, April 13, 2010

Mysql - flush-hosts

My organization's mysql server always needed to execute mysqladmin -flush-hosts command (1 week interval). I don't want to do that everytime our web server could't contact its database server. So what am I to do? Well, I tried using cron but the mysql server need to be authenticate to run mysqladmin command. At last, I found one solution. EXPECT! How?

Make sure you install expect in your mysql server (Centos Linux). Just issue command

yum install expect

Then, make a script file like this:

#!/usr/bin/expect
set timeout 20
spawn /usr/bin/mysqladmin -p flush-hosts

expect "Enter password: "
send "yourmysqlrootpasswd\r\n"

save this script and add this script to run in cronjob.

That's it. Done. You might want to chmod this script to 700 first.

Zimbra - List all Members in Distribution List

Somebody asked me how to list all members in a distribution list and put it in a text file. Well, you can't do it in web interface of course, but you can do it using command line. Login as root to your zimbra server and issue this command

zmprov gdl youlist@yourdomain.com > yourtextfile.txt

simple isn't it. Transfer the text file you just created using any secure file transfer software (i.e winscp, filezilla). Then import it to your Excel using delimited to seperate email and non-email column, delete unused column and walllahhhhhhhh...