开发者

Cronjob using CURL/WGET

I want to run a PHP script every 15 minutes using either CURL or WGET.

This PHP file is in a local folder:

/home/x/cron.php

How would I run this using CURL/WGET?

It doe开发者_运维问答sn't work when I try to run

curl /home/x/cron.php

Thank you!


CURL and WGET are more adecuate for URLs like http://myhost.com/cron.php

When the script is offline, you would better run it using php CLI:

Ex:

php -q cron.php


Just do something like this:

/usr/bin/php /home/x/cron.php

cURL/wget is for HTTP actions. If your PHP script is on the same system, you don't want to load it over HTTP. (You can, of course, if it is accessible over HTTP, but I don't think that is what you want.) Just call it directly.

Alternatively, you can set the execute permission on your script and throw in a shebang line for PHP:

#!/usr/bin/php

Then, just put your PHP script in crontab directly.


If you're using CURL or WGET, I believe you'll need to pass in the path as a URL. If you want to run the php script on the command line, you'll need to use the the php CLI

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜