2
从我的shell脚本test.sh我想传递一些参数,PHP脚本,将读他们喜欢:通过shell传递参数在crontab来php脚本
test.sh
php -q /home/user/files/test.php "$1" "$2"
php -q /home/user/files/test.php $1 $2
要测试的参数的流逝我刚刚看了他们像这样(test.php的):
<?php
echo 'Arg 1: ' . $argv[1] ."\n";
echo 'Arg 2: ' . $argv[2] ."\n";
?>
问题是,如果我从shell中运行test.sh用命令:
./test.sh one two
我的PHP脚本读取两个参数就好了(两次):
Arg 1: one
Arg 2: two
Arg 1: one
Arg 2: two
但是,如果我通过运行crontab你无法读取参数和我得到的只有:
Arg 1:
Arg 2:
Arg 1:
Arg 2:
cron作业是这样的:
20 13 * * * /home/user/files/test.sh one two
如何正确地将参数通过cron作业传递给shell脚本,然后传递给php?
哦,它的工作原理。谢谢! – Mark