1

I have created an event that will call a stored procedure every day. But If for any reason the procedure failed to execute I need to be notified so I can look into the problem.

If MySQL is not capable to send an email then what can I do to monitor the procedures?

Thanks

Mike
  • 2,735
  • 11
  • 44
  • 68
  • I think you mean php... mysql can only store data, it cannot 'do stuff' – Cilan Jan 06 '14 at 00:30
  • What are you using as front end? – Mark Jan 06 '14 at 00:30
  • @ManofSnow [really?](http://dev.mysql.com/doc/refman/5.1/en/events.html) – Niels Keurentjes Jan 06 '14 at 00:30
  • According to MySQL: *MySQL does not support it because it introduces security risks. If you want to disregard those risks, you can write and compile a custom UDF into your copy of the MySQL server. It's sounder, though, to email from the application layer.* – Mark Jan 06 '14 at 00:31
  • @NielsKeurentjes, that *cron* thing, and the schedule task you linked does not say you can send email through MySQL – Mark Jan 06 '14 at 00:41
  • 1
    Correct, that's why it's a comment and not an answer. I was just responding to the implication that the question was impossible without PHP, while you can perfectly well schedule an SP with just MySQL. – Niels Keurentjes Jan 06 '14 at 00:43
  • possible duplicate of [How to send email from MySQL 5.1](http://stackoverflow.com/questions/387483/how-to-send-email-from-mysql-5-1) – WebChemist Jan 06 '14 at 01:06
  • 1
    @ManofSnow MySQL has had a built-in [event scheduler](http://dev.mysql.com/doc/refman/5.6/en/events.html) since 5.1, so it can indeed "do stuff" without any external help... errors and warnings raised in scheduled events are written to the MySQL [error log](http://dev.mysql.com/doc/refman/5.6/en/error-log.html). – Michael - sqlbot Jan 06 '14 at 02:31
  • @Michael-sqlbot Good note. I've been in isolation (kidding) for the past 8 years. – Cilan Jan 06 '14 at 02:33

1 Answers1

0

You can simply PUT all your code in a PHP Script and cUrl the link ( via cron ) . In the PHP script tou can use the logic to check weather the execution succeeded or failed. According to that you can use PHP's mail() function to send a mail .

Fawzan
  • 4,738
  • 8
  • 41
  • 85
  • Are you telling me there is way to schedule a page to be triggered in PHP? How can I do that? – Mike Jan 06 '14 at 00:34
  • @Mike on a *nix host, type `crontab -e` and enter `0 * * * * wget -s http://myurl/myresource` to 'hit' the page on the first minute of every hour. You can also invoke PHP directly if you don't want to expose the cron page to the outer world. – Niels Keurentjes Jan 06 '14 at 00:44
  • @NielsKeurentjes I am sorry, I don't know what you mean by nix host. I am have PHP installed on Windows Server 2008 R2. Can you please give me more information on how this works? – Mike Jan 06 '14 at 00:52
  • *nix is just shorthand for 'some Unix-like OS such as BSD, Linux or Solaris'. On Windows you can use the [Windows Task Scheduler](https://en.wikipedia.org/wiki/Windows_Task_Scheduler) for the same end, it's just harder to set up. – Niels Keurentjes Jan 06 '14 at 00:58
  • @Fawzan, We are talking about sending emails from the DB server, not the Web server. – Pacerier Feb 05 '15 at 22:36
  • If you want to solely depend on MySQL to do it, then there is no way you can do it. – Fawzan Feb 06 '15 at 01:34