Email me mysql/sphinx query result

Hi. Here’s just a simple trick which can be useful if you run some long-lasting mysql/sphinx query in a screen or whatever and want to get informed as soon as it’s finished. This works on mysql client level and applicable to MySQL and SphinxQL:

The trick is to use “pager” directive to redirect the output to a mail program:

mysql> pager mail -s "subject" yourname@yourdomain.com
PAGER set to 'mail -s "subject" yourname@yourdomain.com'

The above will redirect the output to yourname@yourdomain.com and the subject will be “subject”.

Then just start your long-lasting query to MySQL:

mysql> select count(*) from feed where ext_key like 'a%';
1 row in set (10 min 35.88 sec)

or SphinxQL:

mysql> select * from huge_index;
20 rows in set (1 min 14.00 sec)

and be informed via email.

November 22nd, 2011 in Tips | tags: Tips Author: Sergey Nikolaev

Leave a comment

Your comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.