使用 WGET 运行 cronjob PHP
我尝试做一个 cron 并每 5 分钟运行一个 url.
I tried to do a cron and run a url every 5 mintues.
我尝试使用 WGET 但我不想下载服务器上的文件,我只想运行它.
I tried to use WGET however I dont want to download the files on the server, all I want is just to run it.
这是我使用的(crontab):
This is what I used (crontab):
*/5 * * * * wget http://www.example.com/cronit.php
除了 wget 之外,还有其他命令可以用来运行 url 而不是下载它吗?
Is there any other command to use other than wget to just run the url and not downlaod it?
推荐答案
您可以通过几种不同的方式告诉 wget 不要下载内容:
You could tell wget to not download the contents in a couple of different ways:
wget --spider http://www.example.com/cronit.php
它只会执行 HEAD 请求,但可能会执行您想要的操作
which will just perform a HEAD request but probably do what you want
wget -O /dev/null http://www.example.com/cronit.php
将输出保存到/dev/null(一个黑洞)
which will save the output to /dev/null (a black hole)
您可能还想查看 wget 的 -q 开关,这会阻止它创建输出
You might want to look at wget's -q switch too which prevents it from creating output
我认为最好的选择可能是:
I think that the best option would probably be:
wget -q --spider http://www.example.com/cronit.php
除非你有一些特殊的逻辑来检查用于请求页面的 HTTP 方法
that's unless you have some special logic checking the HTTP method used to request the page
相关文章