rand
rand

Reputation: 183

Run a scheduled SQL Query

I have an SQL query that I want to run multiple times a day. I want it to be run automatically. Many are saying I should use Cron Job using the following code:

*/4 * * * * wget --spider file.php

It's actually exactly what I want but I really don't know where to run it in my php code.

Upvotes: 0

Views: 1293

Answers (2)

rand
rand

Reputation: 183

This is what I need:

CREATE EVENT event_name
ON SCHEDULE [EVERY interval | AT timestamp]
DO event_content

For those who don't know | means OR

Thank you for the answers guys!

link: MySQL Manual

Upvotes: 1

kmas
kmas

Reputation: 6439

If you use Windows : launch the Task Scheduler with this command : taskschd.msc.

It is a GUI, so I let you manage it, it is not so complicated.

If you use Linux/Unix : you have to use a cron job.

In a shell :

crontab -e

It launches vim editor, so inside it write :

*/4 * * * * php  /directory/to/your/file.php

Or

*/4 * * * * wget http://your_server/file.php

For more information about crontab, read the links in the comments of your question or google it. ;)

Upvotes: 2

Related Questions