CRON 命令每5分钟运行一次 URL 地址

我是 cron 命令的新手,我需要帮助。

我在 http://example.com/check/上有一个脚本。

Cron 每5分钟运行这个 URL 的命令是什么?

我尽力了

*/5 * * * */home/test/check.php

但是我想运行 URL 而不是相对脚本地址。如何做到这一点?

214691 次浏览

Use cURL:

*/5 * * * * curl http://example.com/check/

Based on the comments try

*/5 * * * * wget http://example.com/check

[Edit: 10 Apr 2017]

This answer still seems to be getting a few hits so I thought I'd add a link to a new page I stumbled across which may help create cron commands: https://crontab.guru

To run a url, you need a program to get that url. You can try wget or curl. See manuals for available options.

The other advantage of using curl is that you also can keep the HTTP way of sending parameters to your script if you need to, by using $_GET, $_POST etc like this:

*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1&param2=2'

To run a URL simply use command below easy yess CPanel 100%

/usr/bin/php -q /home/CpanelUsername/public_html/RootFolder/cronjob/fetch.php

I hope this help.

I try GET 'http://example.com/?var=value' Important use ' add >/dev/null 2>&1 for not send email when this activate Sorry for my English

Nothing worked for me on my linux hosting. The only possible commands they provide are:

/usr/local/bin/php absolute/path/to/cron/script

and

/usr/local/bin/ea-php56 absolute/domain_path/path/to/cron/script

This is how I made it to work: 1. I created simple test.php file with the following content:

echo file_get_contents('http://example.com/check/');

2. I set the cronjob with the option server gived me using absolute inner path :)

/usr/local/bin/php absolute/path/to/public_html/test.php

Here is an example of the wget script in action:

wget -q -O /dev/null "http://example.com/cronjob.php" > /dev/null 2>&1

Using -O parameter like the above means that the output of the web request will be sent to STDOUT (standard output).

And the >/dev/null 2>&1 will instruct standard output to be redirected to a black hole. So no message from the executing program is returned to the screen.

Use perfect URL:

*/5 * * * * wget -q -O /dev/null "https://www.example.com/payment/WebhookOrderCron" > /dev/null 2>&1