Running a stored procedure from crontab

10,324

Solution 1

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.

Solution 2

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.

Share:
10,324
Ran
Author by

Ran

Updated on June 05, 2022

Comments

  • Ran
    Ran almost 2 years

    I have the 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 a crontab?