如何使用cron运行php脚本 [英] How to run a php script using cron
问题描述
我有一个php脚本,抓取来自另一个网站的链接。我使用wamp服务器存储这些链接在我的本地系统数据库,但我的互联网速度是这么慢。因此,我可以在我的webhosting服务器上连续运行这个PHP脚本24小时,并存储所有的链接与我的本地系统相同。如果可能,请帮助我。
输入 crontab -e
在/ a终端或通过您的服务器上的PuTTy,输入
类似以下代码的代码,其中m是分钟,h是小时,dom
是一个月的天数等
#mh dom命令
* / 5 * * * * php -f / directory / to / file / filename.php
这将每五分钟运行一次。
如果你想连续运行它(它不是真的做),它需要运行一块棋子,这样的工作,这将运行它从每天9.30-17.30。 / p>
30-59 / 5 9 * * * script.sh
* / 5 10-16 * * * sh
0-30 / 5 17 * * * script.sh
的cron,我建议您阅读它们。
I have a php script that grabs links from another website. I am storing these links in my local system database using wamp server but my internet speed is so slow. I have to refresh the php script in browser after every 10 records.
So, can I run this PHP script on my webhosting server continuously for 24 hours and store all the links same as my local system. If it is possible then please help me.
Type in crontab -e
in the/a terminal or through PuTTy on your server, enter
something to the like of the code below, where m is minutes, h is hours, dom
is days of the month, etc etc etc
# m h dom mon dow command
*/5 * * * * php -f /directory/to/file/filename.php
This will run it every five minutes.
If you want to run it continuously (which it doesn't really do), it needs to be run piece wise, something like this would work, which would run it from 9.30-17.30 every day.
30-59/5 9 * * * script.sh
*/5 10-16 * * * script.sh
0-30/5 17 * * * script.sh
Here are the basics of cron, I suggest you read them.
这篇关于如何使用cron运行php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!