php - Passing $_GET parameters to cron job -
i new @ cron jobs , not sure whether would work.
for security purposes thought making 1 page script looks values (a username, password, , security code) make sure computer , knows 3 can run command.
i made script , works running in browser possible run cron job values?
a example me running
* 3 * * * /path_to_script/cronjob.php?username=test&password=test&code=1234
is possible?
the $_get[]
& $_post[]
associative arrays initialized when script invoked via web server. when invoked via command line, parameters passed in $argv
array, c.
contains array of arguments passed script when running command line.
your command be:
* 3 * * * /path_to_script/cronjob.php username=test password=test code=1234
you use parse_str() set , access paramaters:
<?php var_dump($argv); /* array(4) { [0]=> string(27) "/path_to_script/cronjob.php" [1]=> string(13) "username=test" [2]=> string(13) "password=test" [3]=> string(9) "code=1234" } */ parse_str($argv[3], $params); echo $params['code']; // 1234
Comments
Post a Comment