Hi...
For several reasons I need to call a php script every x minutes.
I need that on several platforms so I started to write a pecl
extension that implements something like a cron service.
I am running my php 5.1.5 always together with apache 2.2.3.
So I made a small pecl that spawns a thread using apache apr functions.
In this thread I want to call a php script, so I do this whenever
the time to execute the script is reached:
TSRMLS_FETCH();
zend_file_handle zfd;
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = <absolute path to php script to execute>
zfd.free_filename = 0;
zfd.opened_path = NULL;
php_execute_script(&zfd TSRMLS_CC);
Obviously I miss something in initing php, because php
crashes in main/streams/streams.c function
php_stream_locate_url_wrapper() when I call php_execute_script()
because the variable
'wrapper_hash' inited at the very beginning in that
function appears to become a bad value.
So I hope someone here can help me or give me some pointers
to get help...
Thanks in advance,
Roland
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
At this point I think one starts wondering whether PHP is the correct
tool for the job...
Jasper
Roland Schwingel wrote:
Hi...
For several reasons I need to call a php script every x minutes.
I need that on several platforms so I started to write a pecl
extension that implements something like a cron service.I am running my php 5.1.5 always together with apache 2.2.3.
So I made a small pecl that spawns a thread using apache apr functions.In this thread I want to call a php script, so I do this whenever
the time to execute the script is reached:TSRMLS_FETCH();
zend_file_handle zfd;
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = <absolute path to php script to execute>
zfd.free_filename = 0;
zfd.opened_path = NULL;php_execute_script(&zfd TSRMLS_CC);
Obviously I miss something in initing php, because php
crashes in main/streams/streams.c function
php_stream_locate_url_wrapper() when I call php_execute_script()because the variable
'wrapper_hash' inited at the very beginning in that
function appears to become a bad value.So I hope someone here can help me or give me some pointers
to get help...Thanks in advance,
Roland
Jasper Bryant-Greene
Director
Album Limited
jasper@album.co.nz
+64 21 708 334 / 0800 425 286
http://www.album.co.nz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5-ecc0.1.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iFcDBQFFG4F8nqZ4vwo6v1gRCjTcAQCYxarnzuhCEyxO5q1AzRQp9Cfu/d3ob22p
/v4OuCnqVQEAnXx/1xYi7awcDtQ2iCS7/a16RHggUyKLStuB/5ZydWQ=
=VNlE
-----END PGP SIGNATURE
For several reasons I need to call a php script every x minutes.
I need that on several platforms so I started to write a pecl
extension that implements something like a cron service.
Why not cron then?
Obviously I miss something in initing php, because php
crashes in main/streams/streams.c function php_stream_locate_url_wrapper()
when I call php_execute_script()
Correct. You're not in a request (you're probably not even in an
identifiable/unique thread context). Both are fixable by spinning up a
context at thread startup and either (A) wrapping a request
activate/deactivate around that timer, or (B) wrapping the
activate/deactivate just inside your thread context (giving you a
single-uberlong-running request).
because the variable
'wrapper_hash' inited at the very beginning in that
function appears to become a bad value.
Which tells me that both of the issues above are relevant.
But coming back to the first question: What's wrong with cron?
-Sara
Hi Sara...
Thanks for your reply...
Sara Golemon schrieb:
For several reasons I need to call a php script every x minutes.
I need that on several platforms so I started to write a pecl
extension that implements something like a cron service.Why not cron then?
I love cron, but I am mainly (85%) on windows with my apps and
want to have a simple and easy setup and not a bunch of
applications/services to install. There is just the apache service
bringing in php and my pecl. All other solutions I know are much more
voluminous and have more errorpoints.
Obviously I miss something in initing php, because php
crashes in main/streams/streams.c function php_stream_locate_url_wrapper()
when I call php_execute_script()Correct. You're not in a request (you're probably not even in an
identifiable/unique thread context). Both are fixable by spinning up a
context at thread startup and either (A) wrapping a request
activate/deactivate around that timer, or (B) wrapping the
activate/deactivate just inside your thread context (giving you a
single-uberlong-running request).
Do you have some example / skeleton stuff for this
or can you give me a pointer on this where to find?
Many thanks in advance,
Roland
I love cron, but I am mainly (85%) on windows with my apps and
want to have a simple and easy setup and not a bunch of
applications/services to install. There is just the apache service
bringing in php and my pecl. All other solutions I know are much more
voluminous and have more errorpoints.
Last I checked, Windows has this "at" command, the underpinnings of
which are remarkably similar (read: stolen from) the Un*x "at" command
upon which "cron" (and Windows "Scheduled Tasks") are built.
So you could probably use "at" on all systems reliably, with minor (or
no) tweaks to anything.
If not, I'm betting that you could bundle an opensource "cron" into
your distribution process a heck of a lot faster and more reliably
than hacking up a bogus cron-like substance within PHP...
YMMV
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Hi Richard,
Richard Lynch schrieb:
I love cron, but I am mainly (85%) on windows with my apps and
want to have a simple and easy setup and not a bunch of
applications/services to install. There is just the apache service
bringing in php and my pecl. All other solutions I know are much more
voluminous and have more errorpoints.Last I checked, Windows has this "at" command, the underpinnings of
which are remarkably similar (read: stolen from) the Un*x "at" command
upon which "cron" (and Windows "Scheduled Tasks") are built.So you could probably use "at" on all systems reliably, with minor (or
no) tweaks to anything.If not, I'm betting that you could bundle an opensource "cron" into
your distribution process a heck of a lot faster and more reliably
than hacking up a bogus cron-like substance within PHP...
I tried the "AT" thingy also, but I am not very confident about
errorlogging and it opens up an IMHO too big difference in Windows
and Unix handling of my app's installation and maintenance process,
so I think I will give my cron solution a try...
Roland
I tried the "AT" thingy also, but I am not very confident about
errorlogging and it opens up an IMHO too big difference in Windows
and Unix handling of my app's installation and maintenance process,
so I think I will give my cron solution a try...
But they ARE different OS. When you want the OS to do something for
you outside of PHP, you cannot necessarily use the same techniques.
You have to be OS aware at that stage.
If the code is run on a MAC, would you need a different mechanism again?
--
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
I tried the "AT" thingy also, but I am not very confident about
errorlogging and it opens up an IMHO too big difference in Windows
and Unix handling of my app's installation and maintenance process,
so I think I will give my cron solution a try...But they ARE different OS. When you want the OS to do something for
you outside of PHP, you cannot necessarily use the same techniques.
You have to be OS aware at that stage.If the code is run on a MAC, would you need a different mechanism
again?
OS X, no, you would not need a different mechanism, because OS X is
pretty much FreeBSD+OpenBSD+AppleGUICode.
So it has a perfectly fine cron/at command.
MacOS 9.x and below, if PHP even runs on it, I suppose you have a
point, except I don't think anybody has seriously gotten PHP to run
stable on MacOS below X -- could be wrong, of course.
There are probably other OSes out there that PHP runs on, like TiVo,
where you have no "at" command...
Good Luck!
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?