Cronjob Apache module v CGI

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I seem to remember strong opinions were expressed (possibly by Jerry
Stuckle) over which was best for running cronobs and I think at the time I
nodded and thought they were very valid points. I think CGI was the way to

I'm about to build a script to query the sessions database and clean up
reserved items that the customer didn't follow through on.

I currently have PHP running as an Apache module and I'm not as comfortable
as I'd like to be in Linux so would like to avoid fiddling if the security
implications are not overwhelmingly pro-CGI.

As a side, and this will undoubtedly reveal the level of my Linux/Apache
ignorance, is it possible to have PHP bound into Apache for the customer
facing/HTTP side of things and also create a CGI interface for the cronjobs?


Re: Cronjob Apache module v CGI

I would run scripts as scripts and web pages as web pages. It would
surprise me if PHP was not also installed as CLI interpreter. Just open
a terminal on the machine and type:

php -v

This will show the PHP version of the CLI interpreter or a message
"command not found" if it is not installed.

But if you want to call it as a web page, you can use a simple browser,
like lynx or wget in the CRON job.

In both cases, note that CRON sees output as something that went
possibly wrong and will try to mail it to you. So you better redirect
the output of the browser or the script to a log file.

Personally, I would just use a PHP script and not use a browser from
CRON if I don't need it.

Good luck,
Willem Bogaerts

Application smith
Kratz B.V. /

Re: Cronjob Apache module v CGI

On 11/10/2010 5:49 AM, +mrcakey wrote:
Quoted text here. Click to load it

It wasn't I - I have no problem with cron jobs in general; I do have a
problem with the misuse of cron jobs (or other things), but that doesn't
seem to be the problem here.

As long as your hosting company allows you to run cron jobs, this seems
like a good way to go.  PHP runs fine as a CLI application as well as
under a web server.  And I've never seen a server where just one is
installed (although it's possible, I guess).

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Cronjob Apache module v CGI

Quoted text here. Click to load it

Methinks you're confusing CGI (Common Gateway Interface) with CLI (Command
Line Interface).

Quoted text here. Click to load it

Running CLI scripts is entirely independant of apache.  Why would you need
to involve a web server in a background script?

Quoted text here. Click to load it

I suppose it's possible, but I can't think of a good reason to do it.  Try
the following at the command line:

which php

Should tell you if you have a php CLI binary installed.  It's usually in
/usr/bin/php or /usr/local/bin/php, depending on your installation.

then, you can run any of your scripts like so:

php scriptName.php arg1 arg2

Site Timeline