Page 1 of 1
executing cron job from mysql trigger?
Posted: Wed Jun 20, 2007 11:43 pm
by thamizhchelvan
Hi,
Is it possible to execute cron job from an mysql trigger?. OR
I want to execute a cron job from any mysql resource trigger,stored procedure,..etc.
Posted: Wed Jun 20, 2007 11:50 pm
by feyd
Why would you want to execute a cron job based on a trigger? Why wouldn't the cron job monitor MySQL?
Posted: Thu Jun 21, 2007 12:01 am
by thamizhchelvan
feyd wrote:Why would you want to execute a cron job based on a trigger? Why wouldn't the cron job monitor MySQL?
I am working on a project, where data are inserted from an automated machine [I don't know exactly how this happen],while inserting I need to check the data, if any new record is found I need to send a mail.
Posted: Thu Jun 21, 2007 12:11 am
by feyd
This "automated machine" directly connects to MySQL? Could it be changed to connect to a PHP page or something else?
Posted: Thu Jun 21, 2007 12:24 am
by thamizhchelvan
feyd wrote:This "automated machine" directly connects to MySQL? Could it be changed to connect to a PHP page or something else?
No...! They have just given me mysql database only. But one thing is sure, they are not using PHP for that machine.
Posted: Thu Jun 21, 2007 10:03 am
by ReverendDexter
Is there a reason it needs to be time based? Or would it be acceptable if it just mailed you every time it got a new row (or 10 new rows, or...)?
Posted: Thu Jun 21, 2007 11:50 pm
by thamizhchelvan
ReverendDexter wrote:Is there a reason it needs to be time based? Or would it be acceptable if it just mailed you every time it got a new row (or 10 new rows, or...)?
Yes, I want to just mail for every new rows inserted
Posted: Fri Jun 22, 2007 12:40 am
by bdlang
I've not heard of MySQL doing anything remotely like this, although I've not heard of everything.
Why can't the script that performs the insert do this? Or call your script remotely and have your script perform this task?
Posted: Fri Jun 22, 2007 12:47 am
by John Cartwright
is it possible to have a cron job running every minute perform the check for new data?
Posted: Fri Jun 22, 2007 8:16 am
by bdlang
Jcart wrote:is it possible to have a cron job running every minute perform the check for new data?
Yes. VERY inefficient, but yes, technically possible.
Posted: Fri Jun 22, 2007 10:17 am
by ReverendDexter
Jcart wrote:is it possible to have a cron job running every minute perform the check for new data?
I think you're approaching this from the wrong side of the problem. If you want an email as soon as it happens, a cron job isn't what you want; cron jobs are for when you want something to happen at a specific time of your choosing.
I'd be looking in to what it takes to have mysql talk to the outside world, if not a trigger than can directly send the mail, then some other method of using the trigger to cause the event. I know that oracle had the ability to send commands to the shell, perhaps MySQL has something along the same lines?
Posted: Fri Jun 22, 2007 11:33 am
by bdlang
ReverendDexter wrote:
I think you're approaching this from the wrong side of the problem. If you want an email as soon as it happens, a cron job isn't what you want; cron jobs are for when you want something to happen at a specific time of your choosing.
Exactly.