Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Basically I want to create a trigger so that when a field is updated it kicks off a local bash script (or python...whatever) to kick off a workflow (emails, work requests, etc). Is it possible to execute local system scripts/executables from mysql SQL? My google searches have been unsuccessful.

Thanks!

share|improve this question
    
Check this stackoverflow answer: stackoverflow.com/a/1467387/531201 –  hmontoliu Feb 27 '12 at 15:39
add comment

2 Answers

It seems not easy to do it. I think it will be better to do it at the application level if at all possible. You can also query your table for updated rows every x minutes and then execute the script in a cron job.

share|improve this answer
    
To recognize the updated rows easily, you can add a new column updated that should be set to 1 to indicate the updated rows. A trigger after update will set this flag to 1 and your script will clear it. –  Khaled Feb 27 '12 at 15:44
    
Just default the column to 1 instead of abusing a trigger for this. –  adaptr Feb 27 '12 at 16:22
add comment

As already suggested, a once-per-minute cron job that queries a table with pending tasks is the better solution here.

You won't be calling potentially privileged OS code from a database server, and the control over task execution remains firmly in the hands of your application(s).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.