Page 1 of 1

timer based mysql database update

Posted: Sun Nov 07, 2004 2:15 pm
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 ...

Posted: Sun Nov 07, 2004 2:43 pm
by John Cartwright
if your running a windows server you can use Task Scheduler

if you are on Linux you can use chron jobs.

Posted: Mon Nov 08, 2004 3:00 am
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 ?

Posted: Mon Nov 08, 2004 3:11 am
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

Posted: Mon Nov 08, 2004 3:26 am
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

Posted: Mon Nov 08, 2004 2:24 pm
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