# Is there any we we can send alert/email if any query run longer than 5 Minutes?

**URL:** <https://forums.percona.com/t/is-there-any-we-we-can-send-alert-email-if-any-query-run-longer-than-5-minutes/17827>\
**Category:** MySQL & MariaDB\
**Tags:** community, pmm, mysql\
**Created:** [October 4, 2022, 7:42am UTC](https://forums.percona.com/t/is-there-any-we-we-can-send-alert-email-if-any-query-run-longer-than-5-minutes/17827 "2022-10-04T07:42:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavanmysql](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/pavanmysql/32/7152_2.png) [@Pavanmysql](https://forums.percona.com/u/Pavanmysql)\
**Post date:** [October 4, 2022, 7:42am UTC](https://forums.percona.com/t/is-there-any-we-we-can-send-alert-email-if-any-query-run-longer-than-5-minutes/17827/1 "2022-10-04T07:42:35Z")

</div>

how we can send email alert to user if any query run longer than N minutes? using cron job or using PMM tool??

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 4, 2022, 2:06pm UTC](https://forums.percona.com/t/is-there-any-we-we-can-send-alert-email-if-any-query-run-longer-than-5-minutes/17827/2 "2022-10-04T14:06:19Z")

</div>

Hello @Pavanmysql,  
You will first need an SMTP server configured to handle the outbound email sending aspect. You can use a dummy gmail account or set up a simple SMTP daemon. After that, you can do this via a cron script that you will need to write. You can query `performance_schema.processlist` where time \> 60 to return any queries running longer than 60s. Craft that result into an email and then send it.
