StephenS
Nov 01 2015

MySQL/MariaDB query timeout - use cron
0  3K+ {{tagitem.name}}
Okay, so if you ever worked on a big project, and you had to manage some DB, regardless of storage engine, have you wondered what happens if some big *sql query occurs? Well for MySQL/MariaDB there is no timeout on a query, so you are on your own.

To be honest, this is not a rocket science, but you will save yourself from a lot of trouble in the future, if you only write a simple bash/perl script which runs on crobjob once in a while.

If you don't know bash, this script is very useful.
This should go in your cronjob:
* * * * * root /your/path/to/script -t 200 -s -K

Where -t is param for time, in seconds, therefore this will kill any query which runs longer than 200s.

If you are not familiar with crontab, read this asap.

Please Login or Sign Up to leave a reply.