Re: scheduling jobs for php
| From: | Lars Torben Wilson | Date: | Tue, 02 Jan 2001 22:19:17 +0000 |
| Subject: | Re: scheduling jobs for php | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-42713@lists.php.net to get a copy of this message | ||
This isn't a list for questions and answers. It's for development of
PHP, not development in PHP. You should use php-general for that
(signup at http://www.php.net/support.php).
That said:
matt.wong@tumbleweed.com writes:
> Hello,
>
> Any help you could offer would be greatly appreciated here.
>
> In a nutshell:
> - how can I run a PHP script from the command line when PHP is installed
> as an Apache module, so that I can execute it using cron?
> - is there any better way to solve the problem of executing a PHP script
> as a scheduled task?
>
> Here's the long version:
>
> I would like to schedule some tasks to be run at some time in the future
> either once or on a recurring basis. Furthermore, I would like these tasks
> to be defined in a PHP script, so that I can leverage other PHP code, and
> avoid code redundancies and inconsistencies. The problem is that the only
> way I know how to schedule tasks is with cron or at, and using those tools,
> I wouldn't know how to run a PHP script (unless I install PHP as a CGI
> program instead of an Apache module) other than calling a separate program
> that simulates a browser calling up a page. But that still doesn't solve
> the problem, because that would mean that anyone could call up the page to
> run this script, and I only want the system to be able to run the script at
> the specified time(s).
You don't need to install the CGI version instead of the module. It's
just a program. Compile without --with-apxs or --with-apache and copy
the resultant 'php' executable somewhere useful. It's not either-or;
as long as you don't tell Apache to try to use the CGI version you'll
have no conflict.
Otherwise, you'll need to cron a lynx or wget or something, as you
mentioned. Just set an Apache rule to only allow access to that page
from the local machine if you don't want others looking at it.
> Any suggestions on how to do this (using PHP as an Apache module), either
> with existing PHP functionality, or by extending PHP's functionality? I'd
> be happy to write an extension for this if necessary, but I'd need some
> guidance on the best way to implement it.
>
> Thanks, and happy New Year!
> -Matt
Hope this helps,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+