Cron job with page that redirects



I’ve setup a cron job on a php script that redirects to/from other pages. (i.e. the cron job loads page 1, page 1 checks for errors, if it finds them it reloads itself, if not it goes to page 2…page 2 checks for errors, if not, goes back to page 1, etc.)

It runs fine in a browser (navigating to However, in the cron job, it never redirects to page 2, so the script never fully completes.

Do cron jobs just not handle redirects, or am I missing something?



Yeah, you’re missing something. Your mixing two different things.

First of all, they way a web site works is this:

  1. The machine hosting the site is running a type of program called an HTTP server (Apache HTTP Server on DreamHost).

  2. The person visiting the site is running a type of program called an HTTP client (web browsers).

  3. The HTTP client connects to the HTTP server and sends a request, and the HTTP send a response back.

  4. The HTTP server will execute a CGI program (PHP, Perl, Python, etc) to handle certain requests. These programs are run in a special “CGI environment” setup by the HTTP server.

  5. The CGI program output is passed through the HTTP server back to the HTTP client.

  6. If the output is a redirect, the HTTP client is responsible for processing it.

So what you have done is left out the HTTP server, CGI environment, and HTTP client. Ooops! Either you need to program a script that can do the task without them, or you need to bring those three things into the picture somehow.

:cool: [color=#6600CC]Atropos[/color] |