The ?type=daily
argument (ending up in the $_GET
array) is only valid for web-accessed pages.
You'll need to call it like php myfile.php daily
and retrieve that argument from the $argv
array (which would be $argv[1]
, since $argv[0]
would be myfile.php
).
If the page is used as a webpage as well, there are two options you could consider. Either accessing it with a shell script and Wget, and call that from cron:
#!/bin/sh
wget http://location.to/myfile.php?type=daily
Or check in the PHP file whether it's called from the command line or not:
if (defined('STDIN')) {
$type = $argv[1];
} else {
$type = $_GET['type'];
}
(Note: You'll probably need/want to check if $argv
actually contains enough variables and such)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…