proactive scripts in PHP - is it possible?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

proactive scripts in PHP - is it possible?

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
dodga
Forum Newbie
Posts: 9
Joined: Sat Feb 07, 2004 2:10 pm
Location: Benztown, Germany

Post 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:
Post Reply