SQL update timed?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Blackmirth
Forum Newbie
Posts: 6
Joined: Sun Sep 30, 2007 12:09 pm

SQL update timed?

Post by Blackmirth »

How is it possible, if it is, to make the contents of a MySQL table/cell/column whatever update every say... twenty minutes?

Sorry if this is quite a stupid sounding question. I am new. Ignorance is my excuse.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Cron.

But the question of what are you trying to do must be asked.
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Post by Josh1billion »

Create a PHP file which executes the update queries you need. Then, like feyd said, use Cron Jobs (in your control panel) to have that PHP script run every twenty minutes.
Blackmirth
Forum Newbie
Posts: 6
Joined: Sun Sep 30, 2007 12:09 pm

Post by Blackmirth »

feyd wrote:Cron.

But the question of what are you trying to do must be asked.
Not really trying to do anything, really. It was more curiosity really.
Although I am sure it will come into use.

I have never heard of Cron before, or at least only as a misspelling of corn. I also cannot find any option in my hosts' panel.
Would there be any alternative to this?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Google "cron jobs" or "crontab". It's a *nix software. If your host is windows, you'll have to use the windows task scheduler.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Blackmirth
Forum Newbie
Posts: 6
Joined: Sun Sep 30, 2007 12:09 pm

Post by Blackmirth »

Thanks. Although, surely if I am running it, that would mean keeping my computer on all the time?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Something to remember is that if the results of this information doesn't need to be done on a regular basis, there's no need for a cron script. Instead the functionality could be incorporated into existing site code.

As an example, a user wished to update data about who was online at his website every few minutes. The problem was, this information was only potentially useful if someone was looking at it (on a single page.) So instead of setting up a cron job, they could have simply told the page to fetch the data on-demand.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i actually do what feyd is talking about on a popular eCommerce site, and its not a trivial function such as updating a whoisonline script but a very important site function.

Although i will say, it is important to lock the table if you are doing something of this kind, or locking the file your working as i do, otherwise it can (and will) cause problems on concurrent connections.

Good luck
Post Reply