From: Mathijs Brands <mathijs@ilse.nl>
To: Bernie Huang <bernie.huang@ec.gc.ca>
Cc: PHP_DB <php-db@lists.php.net>
Cc: PHP_General <php-general@lists.php.net>
Cc: PGSQL-SQL <pgsql-sql@postgresql.org>
Cc: PGSQL-GENERAL <pgsql-general@postgresql.org>
Subject: Re: [SQL] a script that queries database periodically
Date: Mon, 27 Nov 2000 20:44:44 +0100
Message-ID: <20001127204444.C57613@ilse.nl> (raw)
In-Reply-To: <3A22B485.E8963417@ec.gc.ca>
References: <3A22B485.E8963417@ec.gc.ca>
On Mon, Nov 27, 2000 at 11:22:45AM -0800, Bernie Huang allegedly 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
Sure you can. You can configure PHP to run seperately from any webserver.
You would then be able to write PHP scripts that can be used just like any
other UNIX scripts, for instance from a crontab.
I don't know if you've configured and built PHP before, but it is actually
not that difficult. However, be sure to look at the INSTALL file that comes
with PHP. What it comes down to is probably the following:
1 - extract PHP source
2 - change to the PHP source directory and execute the following configure
command:
./configure --prefix=/usr/local/standalone-php --without-mysql --with-pgsql
3 - build the source by giving the make command
4 - do a 'make install' after PHP has been succesfully build
A bit off-topic, but I hope this is helpful.
Cheers,
Mathijs
Ps. I just thought of something else. You could write a PHP script that runs
under apache (like your're used to) and request it with wget, lynx or a
similar tool from a crontab. That way you wouldn't need to configure a new
PHP installation.
--
"A book is a fragile creature. It suffers the wear of time,
it fears rodents, the elements, clumsy hands."
Umberto Eco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: mathijs@ilse.nl, bernie.huang@ec.gc.ca, php-db@lists.php.net, php-general@lists.php.net, pgsql-general@postgresql.org
Subject: Re: [SQL] a script that queries database periodically
In-Reply-To: <20001127204444.C57613@ilse.nl>
References: <3A22B485.E8963417@ec.gc.ca> <20001127204444.C57613@ilse.nl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox