Page 1 of 1

proactive scripts in PHP - is it possible?

Posted: Wed Apr 14, 2004 6:53 pm
by davidklonski
Hello

I know that PHP acts on a client request. That is the code only runs as a response.
I was wondering whether it is possible to have a PHP script which can run proactively in the server without being triggered by a client request.

Examples:
A scheduler could send mails every hour...
database cleanup could run every hour...

does anyone know if it is possible, or do I need some other server-side technology for that?

thanks

Posted: Wed Apr 14, 2004 7:55 pm
by timvw
I've recently read at zend.com somewhere that this is not possible (yet) and you should use cronjob + wget for this stuff.

Posted: Thu Apr 15, 2004 3:08 am
by JayBird
use cron jobs to schedule scripts to run at set times

do a search for cron on this site, been discussed loads before

Mark

Posted: Sun Apr 18, 2004 10:35 am
by dodga
Depends on what operating system you intend to use.

On Windows you can simply execute 'php.exe --help' in a Dosbox to see what parameters it accepts (e.g. php -q script.php would parse and execute the script).

On Linux (probably other *ix, too) you need to build PHP as CGI-Binary; on Debian (probably other Linuces, too :P ) you may want to apt-get install php4-cgi. php4 is then available as normal binary like find and the like. Again, php4 --help tells you how to call it properly.

HTH :D

Forgot to mention that you will need some kind of scheduler to do automated stuff 8)
PHP4 is very nice for shell-scripts indeed :lol: