Thread: Re: [SQL] a script that queries database periodically

Re: [SQL] a script that queries database periodically

From
"Poul L. Christiansen"
Date:
I have a bash script in crontab with the following line:
"lynx -dump
http://127.0.0.1/postgres/myPhpFile.php>${currentDir}php_output.html"

You can also just put that line directly into crontab.

Poul L. Christiansen

Bernie Huang wrote:

> Hello,
>
> My boss wants me to write a script that will send a email report to him
> monthly with the result of database queries.
>
> For example, an email would be like:
>
> Monthly report
> +----------+---------+---------------+
> | Vehicles | Mileage | # of Signouts |
> +----------+---------+---------------+
> | Vehicle1 | 10324   | 5             |
> +----------+---------+---------------+
> | Vehicle2 | 19384   | 6             |
> +----------+---------+---------------+
> ...
>
> I was thinking of writing up a PHP script and put into crontab, which is
> somehow easier than a shell script, but PHP is an apache module, so I
> cannot execute PHP under crontab (it has to be executed in a browser
> right?).  I guess a shell script is necessary.  So, is it possible to
> call 'psql' and returning its query result and I can use sendmail to
> email the result? Any other idea?
>
> Thanks.
>
> - Bernie
>


Re: [PHP-DB] Re: [SQL] a script that queries database periodically

From
clayton cottingham
Date:
Roberto Mello wrote:
>
> Jason wrote:
> >
> > aolserver is a web/application server.  PHP is a server-side scripting
> > language.  Why exactly *should* it have a job scheduler?
> >
> > Some (such as myself) might also ask why should a web server have a job
> > scheduler, but that's a thread for a different list :)
>
>         Because PHP is supposed to solve web development problems. And this is
> one of them. It's very useful.
>
>         -Roberto
> --
> Computer Science                        Utah State University
> Space Dynamics Laboratory               Web Developer
> USU Free Software & GNU/Linux Club      http://fslc.usu.edu
> My home page - http://www.brasileiro.net/roberto

heya,

IMHO
it depends on why you are querying the db

if you need internet access data
such as how fast its querying or what have you
then yes php could be useful

if you need reports generated and mailed to someone
a crond shell script would seem more logical

Re: [PHP] Re: [PHP-DB] Re: [SQL] a script that queries database periodically

From
Joe Stump
Date:
>     Because PHP is supposed to solve web development problems. And this is
> one of them. It's very useful.

Why solve one that is already solved? PHP isn't here to reinvent the wheel -
get crontab and quit crying.

--Joe


>
>     -Roberto
> --
> Computer Science            Utah State University
> Space Dynamics Laboratory        Web Developer
> USU Free Software & GNU/Linux Club     http://fslc.usu.edu
> My home page - http://www.brasileiro.net/roberto
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
================================================================================
= Joe Stump                joestump98@yahoo.com         http://www.miester.org =
================================================================================
      Need a programmer? http://www.google.com/search?q=joe+stump+resume

Re: [SQL] a script that queries database periodically

From
Mathijs Brands
Date:
On Mon, Nov 27, 2000 at 10:44:39PM +0100, Poul L. Christiansen allegedly wrote:
> I have a bash script in crontab with the following line:
> "lynx -dump
> http://127.0.0.1/postgres/myPhpFile.php>${currentDir}php_output.html"
>
> You can also just put that line directly into crontab.
>
> Poul L. Christiansen

Be sure to redirect the output of the command in your crontab to /dev/null
or something similar. If you don't, the output (HTML) will be emailed to
you each time the script is run. Whether this side effect is desirable is
of course up to you (or your boss, for instance).

Getting even more off-topic,

Mathijs
--
"Where is human nature so weak as in a bookstore!"
        Henry Ward Beecher  (1813-1887)

Re: [SQL] a script that queries database periodically

From
Roberto Mello
Date:
"Poul L. Christiansen" wrote:

> > I was thinking of writing up a PHP script and put into crontab, which is
> > somehow easier than a shell script, but PHP is an apache module, so I
> > cannot execute PHP under crontab (it has to be executed in a browser
> > right?).  I guess a shell script is necessary.  So, is it possible to
> > call 'psql' and returning its query result and I can use sendmail to
> > email the result? Any other idea?

    PHP does not have a scheduling facility? AOLserver (the web/application
server that powers AOL) has had such facility (and many many others for
db-backed websites) since 1995. ns_schedule_proc.
    http://www.aolserver.com

    -Roberto
--
Computer Science            Utah State University
Space Dynamics Laboratory        Web Developer
USU Free Software & GNU/Linux Club     http://fslc.usu.edu
My home page - http://www.brasileiro.net/roberto

Re: [PHP-DB] Re: [SQL] a script that queries database periodically

From
Jason
Date:
On Mon, Nov 27, 2000 at 02:56:59PM -0700, Roberto Mello wrote:
>
>     PHP does not have a scheduling facility? AOLserver (the web/application
> server that powers AOL) has had such facility (and many many others for
> db-backed websites) since 1995. ns_schedule_proc.
>     http://www.aolserver.com

aolserver is a web/application server.  PHP is a server-side scripting
language.  Why exactly *should* it have a job scheduler?

Some (such as myself) might also ask why should a web server have a job
scheduler, but that's a thread for a different list :)


Re: [PHP-DB] Re: [SQL] a script that queries database periodically

From
Roberto Mello
Date:
Jason wrote:
>
> aolserver is a web/application server.  PHP is a server-side scripting
> language.  Why exactly *should* it have a job scheduler?
>
> Some (such as myself) might also ask why should a web server have a job
> scheduler, but that's a thread for a different list :)

    Because PHP is supposed to solve web development problems. And this is
one of them. It's very useful.

    -Roberto
--
Computer Science            Utah State University
Space Dynamics Laboratory        Web Developer
USU Free Software & GNU/Linux Club     http://fslc.usu.edu
My home page - http://www.brasileiro.net/roberto

v7.1 Beta?

From
"Gordan Bobic"
Date:
I seem to remember someone saying that v7.1 was supposed to go Beta last
weekend. Are there binary RPMs available? If so, where?

Regards.

Gordan


Re: Re: [PHP-DB] Re: [SQL] a script that queries database periodically

From
"Dan Wilson"
Date:
> Jason wrote:
> >
> > aolserver is a web/application server.  PHP is a server-side scripting
> > language.  Why exactly *should* it have a job scheduler?
> >
> > Some (such as myself) might also ask why should a web server have a job
> > scheduler, but that's a thread for a different list :)
>
> Because PHP is supposed to solve web development problems. And this is
> one of them. It's very useful.

I disagree!  Cronjobs are not a web development problem.  That is something
that should be handled on the server/machine side.  PHP is purely designed
to dynamically create web pages.  It has other things built into it, but
each one interfaces with the web page somehow.  A cronjob doesn't use the
web at all.  The web is an interactive thing and the whole purpose of a job
scheduler is to avoid interaction.

Sure a job scheduler is useful, but it is outside the scope and mission of
PHP.

-Dan


Re: v7.1 Beta?

From
The Hermit Hacker
Date:
being tag'd and tar'd up as source sometime today ...

On Mon, 4 Dec 2000, Gordan Bobic wrote:

> I seem to remember someone saying that v7.1 was supposed to go Beta last
> weekend. Are there binary RPMs available? If so, where?
>
> Regards.
>
> Gordan
>
>

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: v7.1 Beta?

From
Lamar Owen
Date:
Gordan Bobic wrote:
>
> I seem to remember someone saying that v7.1 was supposed to go Beta last
> weekend. Are there binary RPMs available? If so, where?

Not yet.  I usually take a week or less to get the first set of beta
RPM's out -- I like to test things out thoroughly before any release,
even a beta one.

And, right now is a very hectic time for me anyway.  But, rest assured,
you will see RPM's of 7.1 beta shortly after the tarball is released --
I expect to do so within a week of the tarball's release.

Watch this list for the announcement.
--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11