How to run a php url with parameters in cron tab [duplicate]

人走茶凉 提交于 2019-12-01 21:42:06

Ideally running PHP in command line interface (CLI) you would use $argv and $argc globals to pass parameters to the script.

Example: my_php_script.php

 <?
    var_dump($argv);


    php my_php_script.php arg1 arg2


array(3) {
  [0]=>
  string(17) "my_php_script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
}

Hari

Show us your crontab (or at least the row with the PHP script). If you perform it like:

php script.php?param1=123

The above will not work. Instead do it like this:

wget http://localhost/script.php?param1=123&param2=345 -o /dev/null

Then it should work. If not, give more details.

Keep in mind, that the suggestion is JUST AN EXAMPLE. This would imply you have a running web server, that is configured to run PHP files, etc.

Use the global $argv to get command line parameters.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!