I'm newbie in cron commands and I need help.
我是cron命令的新手,我需要帮助。
I have a script on http://example.com/check/
.
我在http://example.com/check/上有一个脚本。
Whats is command for cron to run this URL every 5 minutes?
cron每5分钟运行这个URL的命令是什么?
I tried
我试着
*/5 * * * * /home/test/check.php
*/5 * * * * */ home/test/check.php
But I want to run URL not relative script address. How to do it?
但是我想运行URL而不是相对脚本地址。如何去做?
6 个解决方案
#1
65
Based on the comments try
根据评论试试
*/5 * * * * wget http://example.com/check
[Edit: 10 Apr 2017]
(编辑:2017年4月10)
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
这个答案似乎仍然得到了一些点击,所以我想我应该给我偶然发现的一个新页面添加一个链接,这个链接可以帮助创建cron命令:https://crontab.guru
#2
84
Use cURL:
使用cURL:
*/5 * * * * curl http://example.com/check/
#3
27
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:
使用curl的另一个好处是,如果需要的话,还可以使用HTTP方式将参数发送到脚本中,比如使用$_GET、$_POST等:
*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1¶m2=2'
#4
#5
1
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
我试着得到的http://example.com/?var=value' Important use ' add >/dev/null 2>&1 for not send email when this activate Sorry for my English
#6
1
To run a URL simply use command below easy yess CPanel 100%
要运行URL,只需使用下面的命令,yess CPanel 100%
/usr/bin/php -q /home/CpanelUsername/public_html/RootFolder/cronjob/fetch.php
I hope this help.
我希望这帮助。
#1
65
Based on the comments try
根据评论试试
*/5 * * * * wget http://example.com/check
[Edit: 10 Apr 2017]
(编辑:2017年4月10)
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
这个答案似乎仍然得到了一些点击,所以我想我应该给我偶然发现的一个新页面添加一个链接,这个链接可以帮助创建cron命令:https://crontab.guru
#2
84
Use cURL:
使用cURL:
*/5 * * * * curl http://example.com/check/
#3
27
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:
使用curl的另一个好处是,如果需要的话,还可以使用HTTP方式将参数发送到脚本中,比如使用$_GET、$_POST等:
*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1¶m2=2'
#4
3
To run a url, you need a program to get that url. You can try wget or curl. See manuals for available options.
要运行url,需要一个程序来获取该url。你可以试试wget或curl。有关可用选项,请参阅手册。
#5
1
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
我试着得到的http://example.com/?var=value' Important use ' add >/dev/null 2>&1 for not send email when this activate Sorry for my English
#6
1
To run a URL simply use command below easy yess CPanel 100%
要运行URL,只需使用下面的命令,yess CPanel 100%
/usr/bin/php -q /home/CpanelUsername/public_html/RootFolder/cronjob/fetch.php
I hope this help.
我希望这帮助。