Running a stored procedure from crontab

I have a layout:

Mysql 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 crontab?

+3
source share
2 answers

Try running something like this

mysql -h 'your ipadress' -u user_name –p'12345' mydatabase -e 'CALL my_stored_procedure()'

Just guessing, I don't know if this will work.

+4
source

I think it is better to use events from mysql.

For more information, visit Using Event Planner

Or use the solution suggested by Michael .
Personally, I like to execute mysql using -ss and the socket file:

mysql -S/path_to_sock_file/mysql.sock -u user_name –p'12345' mydatabase -ss  -e 'CALL my_stored_procedure()'

-ss returns the results as plain text.

Greets Arman.

+3
source

All Articles