What do people think about making a cron job call a page by doing a lynx
http://www.site.com/automatedtasks.php every hour?


-----Original Message-----
From: Erik Price [mailto:[EMAIL PROTECTED]]
Sent: February 16, 2002 3:02 PM
To: Rodney Davis
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] scheduled tasks



On Friday, February 15, 2002, at 03:03  PM, Rodney Davis wrote:

> Is currently anyway of doing scheduled tasks with PHP (without using
> crontab)?  For example, using an email script to send out e-mail
> reminders every Monday or something like that?

One way to do it (stole this from my 'Beginning PHP' book [Wrox]):

Store the current timestamp into a file.  Read this file every time some 
commonly-used feature of your site is executed.  Then, when X number of 
seconds has passed beyond the timestamp, execute some other code:

$countfile = "./countfile.txt";
$fp = fopen($countfile, 'r+');
$oldtime = fread($fp);

if ((time()) >= ($oldtime + 24 * 60 * 60 * 7)) {
    // a week has passed since the last time the file was written to
    // execute the code (mail or whatever)
}

rewind($fp);
fwrite($fp, time());
fclose($fp);

or something like that.  NB this code is definitely untested, so it 
probably won't work, but the theory is there.  Also, be sure to take 
into account the security issues of having a file writeable by your web 
server -- I'm assuming you already have experience with this.

Erik



----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to