timer based mysql database update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pimp
Forum Newbie
Posts: 9
Joined: Sat Nov 06, 2004 10:22 am

timer based mysql database update

Post by pimp »

how can i update a mysql database, using php code, or any other program to run in background on server, based on timing. i mean... every 20 minutes to dun the command : UPDATE TABLE SET FIELD = FIELD + X . please help if you know ...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

if your running a windows server you can use Task Scheduler

if you are on Linux you can use chron jobs.
pimp
Forum Newbie
Posts: 9
Joined: Sat Nov 06, 2004 10:22 am

Post by pimp »

it's a linux server. i agree using chron jobs, but what program should i run ? cand c++ use mysql ? or what program should i use ? or just bash scripts ?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i'd say to write the script in the language you know best.
and then make sure cron runs that script every x minutes.
for example 0 * * * * /usr/bin/wget http://localhost/script.php
pimp
Forum Newbie
Posts: 9
Joined: Sat Nov 06, 2004 10:22 am

Post by pimp »

i have just fround on the forum PHP CLI. i think i`ll use that. i didn't know this cand be done, it's much easier this way. the wget think is smart too. thank you for the responses. SOLVED
DMcK
Forum Newbie
Posts: 7
Joined: Tue Nov 02, 2004 4:43 pm

Post by DMcK »

I didn't like running wget because it skewed results of web site access. My host would appear far too often in the logs. So i use this in my cron jobs:

Code: Select all

0 * * * *  php /home/path/to/wherever/code.php > /dev/null
Doug
Post Reply