Running a stored procedure from crontab
I have the layout:
Mys开发者_开发知识库ql DB
DB name: db_name
DB User name: user_name
Password: 12345
Stored procedure: my_stored_procedure
How can I execute "my_stored_procedure" daily from a crontab?
Try to run something like this
mysql -h 'your ipadress' -u user_name –p'12345' mydatabase -e 'CALL my_stored_procedure()'
Just a guess i dont know if it will work.
I think better to use Events from mysql.
For more information please visit Using the Event Scheduler
Or use solution suggested by Michael.
Personally I like to execut mysql using -ss and socket file:
mysql -S/path_to_sock_file/mysql.sock -u user_name –p'12345' mydatabase -ss -e 'CALL my_stored_procedure()'
-ss returns results as a plain text.
Cheers Arman.
精彩评论