tags:

views:

26

answers:

2

I am wondering if I can use a command in a cron job like so:

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

I haven't been able to find anything that says I can or can't so I figured I would ask. I thoughts are that I can't but hopefully someone can tell me for sure.

If that is the case is there a way for me to include a variable in a cron job calling a php script?

Thanks Nick

+2  A: 

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.

BBonifield
A: 

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"
reko_t
Sorry I am fairly inexperienced when it comes to cronjobs. Are you saying that the line above would be in place on my command in the original post?
Nick
Yes. Eg. `0 * * * * wget -q -O /dev/null "http://yourdomain.com/scores.php?date=12%2F05%2F2009` would fetch the URL once an hour.
reko_t
This seems like a cumbersome workaround when PHP already provides a method for passing in command-line arguments.
BBonifield