php cron job with url parameters [moved]

CT Internet

Registered
Feb 24, 2006
3
0
151
php cron job with url parameters

Hi There,

I have read through the forum and have not been able to see this problem described anywhere.

I am trying to execute a php scrip through cron and can successfully do so with the following line:

php /home/MyPath/public_html/cron.php

The problem is that I need to append some parameters to the php scrip like this:

php /home/MyPath/public_html/cron.php?paremeter1=value1&patermeter2=value2

This does not work. I think the error was "File not found". Which is sort of obvious in retrospect since it is a file path based execution.

I then changed the cron to execute a different php file:

php /home/MyPath/public_html/cron_redirect.php

In this file I have the following code:

Code:
<?php
header("Location: http://www.mysite.com/cron.php?paremeter1=value1&patermeter2=value2");
?>
This does not work. I get an email from cron saying:

Status: 302
X-Powered-By: PHP/4.4.1
Location: http://www.mysite.com/cron.php?paremeter1=value1&patermeter2=value2
Content-type: text/html

But my file is not redirected.

Can someone help me please?

Thanks a bunch!
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
If you execute your PHP script via CRON, it is running as CLI (Command Line Interface)
which has a lot of different rules than the normal Web based PHP interface.

Parameters are read as number command line parameters of any other shell script language
which means you need to add spaces to the request between each parameter and use PHP's
added commands for CLI use for reading those parameters.

See the PHP site at http://www.php.net for more information about using CLI based PHP.
 

CT Internet

Registered
Feb 24, 2006
3
0
151
Hi There,

I could get the Lynx option to work. It came back with:

Your Terminal type is unknown!

Enter a terminal type: [vt100]
TERMINAL TYPE IS SET TO vt100
(B)0[?7h[?1h=Getting http://www.mysite.com/index.php?option=option
Looking up www.mysite.com 
Making HTTP connection to www.mysite.com
Sending HTTP request. 
HTTP request sent; waiting for response.


[?1l>

But the script does not execute.

The script takes a long time to execute since I am throtteling several emails being sent each with a 10 seccond interval between them. Could this be the reason?

It works when I open the page manually in IE.

Thank you,

Soren
 

CT Internet

Registered
Feb 24, 2006
3
0
151
Hey!

Got tit to work by parsing the arguments to the file like this:

php /home/public_html/mysite/index.php var1=value1 var2=value2

Just in case someone has the same problem!

Thank you for the help!