On 17 Feb 2002, at 21:01, Jennifer Downey wrote:

> Would someone please help? I have looked everywhere and can not find
> how to update a database at a certain time.
> I am trying to get this to update at midnight instead of every time
> the browser refreshes. My hosting service has cron jobs but I don't
> understand how to set them up. Is there a way to set this code up to
> do what I need?

I don't know how to run php code as a freestanding executable but it can be 
done. For cron, heck, I never remember the syntax either and my gui is no 
help so I always go this page that my host put up:


Rule is not to run anything at a give time.

So the following should probably at set to a different time. See above link 
for breakdown of fields (what they mean etc.).

Be sure that the "time" you think it is is actually the time it will run. My 
server for instance runs on GMT not my CST or even the EST where the 
server is located.

# Execute the "vnukelog" command at 12:00 midnight (0 0) on August 19
# (8) (aug).  
0 0 19 8 *  /usr/local/bin/vnukelog

You can always do a "man cron" to see info for your system.

Any hosting company worth anything will help you with at least once.

I'm not sure where STDOUT goes, I always have it sent to me via email by 
putting my email at the top of the cronfile (see above url of info on that).  
You seem to be printing to STDOUT  in the PHP snippet you sent.

I think you only want to do the update in your PHP script. I'm sure 
someone will show you how to do this via PHP, I don't know, I use Perl for 
this stuff.  Here's how I'd do it in Perl (MyDBI is a private module).

I suggest you check to make sure that your cron job runs properly (you'll be 
suprised at the number of times something happens where it doesn't).

use strict;
use MyDBI;

eval {
        my $dbh = MyDBI->new(
                data_source =>  'dbi:mysql:database=x;host=x',
                username    =>  '',
                password    =>  ''',

        my $sql = "SELECT Subject,body,article_id,Born FROM news WHERE 
visibility is NULL ORDER BY article_id LIMIT 500";
        my $sth = $dbh->{dbh}->prepare($sql);

if($@) {
        print "This script no go: $@";



Answering Your Questions About Brazil

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to