如何每分钟自动运行php脚本,无需访问该页面? [英] how to run php script automatically every minute without access to that page?
问题描述
我正在开发网站,当他们注册到我的网站时,会自动向用户发送电子邮件。我从互联网搜索,他们大多数人说我必须使用cron工作;现在的大问题是关于cron工作。我不怎么写它,以及如何执行它。任何人都可以给我一些例子吗?
I'm developing website that will send email back to user automatically when they registered to my website. I have searched from internet, most of them said that i have to used cron jobs; the big problem foo me now is about cron jobs. I don't how to write it and also how to execute it. Can anyone gives me some example about it?
提前感谢。
推荐答案
如果我们假设您要运行的脚本位于 /home/me/myscript.php
,那么您所需要做的就是创建一个cron作业
If we assume that the script that you want to run is located at /home/me/myscript.php
then all you need to do is create a cron job that will run that script every minute.
几个托管公司有一个接口(例如cPanel),可以轻松添加一个cron任务。您还可以通过编辑相关的cron作业并添加以下内容来添加cron任务:
Several hosting companies have an interface (cPanel for instance) that will allow you to add a cron task easily. You can also add the cron task by editing the relevant cron job and adding:
*/1 * * * * /usr/bin/php /home/me/myscript.php > /dev/null
这篇关于如何每分钟自动运行php脚本,无需访问该页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!