开发者

Cron Jobs calling a PHP script with variables

开发者 https://www.devze.com 2023-01-19 02:45 出处:网络
Is it correct to use the following command in a cron job: /usr/bin/php -q /home/**/public_html/scores.php?date=12/05/2009

Is it correct to use the following command in a cron job:

/usr/bin/php -q /home/**/public_html/scores.php?date=12/05/2009

I haven't found any supportive article / material to answer it, hence i am putting forth this question to the community.

So the question is is there a way for me to include a 开发者_运维问答variable in a cron job calling a PHP script?

Thanks


in cron jobs, here is how you should pass the argument

/usr/bin/php -q /home/**/public_html/scores.php date=12/05/2009

*take note there is no "?"


Nick, take a gander at http://php.net/manual/en/features.commandline.php.

What you want to do is pass arguments in in the form of php -f scores.php '12/05/2009'. At that point, you'll just look at the $_SERVER['argv'] to get the value.


You can setup a cronjob to fetch it from your server:

wget -q -O /dev/null "http://yourdomain.com/scores.php?date=12%2F05%2F2009"


I had the same problem, my quick workaround was to create a seperate file with the parameters declared inside it, and then 'include' the original Cron file.

i.e.:

$date = '12/05/2009';

include ('scores.php');


Use this

/usr/bin/php -q /home/**/public_html/scores.php 12/05/2009
0

精彩评论

暂无评论...
验证码 换一张
取 消