Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Schedule a Stored procedure

Status
Not open for further replies.

Deeba

Programmer
May 8, 2002
32
0
0
CA
Hello,

I'm just getting back into mySql for a client project, and have a question.

I'm using MySql 5.0, with the phpMyAdmin front end.

I would like to schedule a simple delete to run every few days on my database. I assume I have to put the Delete into a stored procedure, but were to save it, and how to call it is where I am stuck. What should I be trying?

Thanks a bunch,
~Deeba
 
It depends a bit on your OS, but the idead is that this command should be triggered from outside. This "outside" must be scheduled. If you are on Windows, use a "scheduled task". If on *nix, use CRON.

Both can be instructed to run a batch file containing the call to the command you want to run. It can take the shape of:

Code:
echo "call <yourProcedure>();"|mysql -h <hostname> -u <databasename><username>

Because you cannot type a password in a batch file and because you do not want it to show up in a history either, it is good to make a user in MySQL that has no password an only execute rights on the procedure.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks DonQuichote,

I'm using a Mac, but the database is running on the Client's ISP, I will check to see which OS it is using.

The different MySql account is a good idea.

~Deeba
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top