开发者

Pass a value to a script in cron

I'm running a script in cron, and would like to pass a value to the script.

I'm trying to do something like this in crontab:

Where the variable would be read by $_GET in the script.

I can't seem to find an answer anywhere, thanks for your help!


You probably want to use argv:

/path/to/script.php x y z

Then, in script.php:

print_r($argv);

Which gives you:

Array
(
    [0] => ./script.php
    [1] => x
    [2] => y
    [3] => z
)


You seem to be confusing a webserver and a shell.

/home/cron/some_script.php

Is your script. If you want to pass things into it on the command line you would do:

/home/cron/some_script.php arg1 arg2

And parse the arguments in your script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜