executing cron job from mysql trigger?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thamizhchelvan
Forum Newbie
Posts: 23
Joined: Tue May 08, 2007 2:50 am

executing cron job from mysql trigger?

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why would you want to execute a cron job based on a trigger? Why wouldn't the cron job monitor MySQL?
thamizhchelvan
Forum Newbie
Posts: 23
Joined: Tue May 08, 2007 2:50 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This "automated machine" directly connects to MySQL? Could it be changed to connect to a PHP page or something else?
thamizhchelvan
Forum Newbie
Posts: 23
Joined: Tue May 08, 2007 2:50 am

Post 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.
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post 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...)?
thamizhchelvan
Forum Newbie
Posts: 23
Joined: Tue May 08, 2007 2:50 am

Post 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
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

is it possible to have a cron job running every minute perform the check for new data?
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post 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.
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post 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?
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post 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.
Post Reply