Recently in a project, you need to pass the parameters in Linux to execute PHP files regularly, online query data, there is really relevant information, now organized as follows:
1.linux Execute PHP file
#{php Install bin path} {php file path} {requires parameter 1 parameter 2 parameter 3}
#各参数之间, separated by a space
#查看php安装bin路径 executable which php command /usr/bin/php /local/www/index.php 111 222333
2. Receiving Parameters
In general, PHP receives the command line passed over the parameters, $argv save all the parameters of the array, $ARGC save the number of parameters (the form of passing parameters and shell script is a bit similar), if the command to execute:/usr/bin/php/local/www/ index.php 111 222 333, print the results as follows:
<? PHP // index.php File Print_r ($argv); Print_r ($argc);? >
<? PHP // the $ARGV is receiving an array $argv=array( ' 0 ' = '/local/www/index.php ',//file path ' 1 ' =>111, //First parameter ' 2 ' =>222, //second parameter ' 3 ' =>333 //third parameter )//$ ARGC received is the number of parameters, this example returns: 4?>
For more information on PHP scheduled tasks, refer to taskphp
Linux command line pass parameters execute PHP files regularly