我想每天午夜运行一个 PHP 脚本.在研究了如何做到这一点之后,似乎实现这一目标的最佳方法是使用 CRON 作业.
I would like to run a PHP script every day at midnight. After research on how to do this, it appears that the best way to achieve this is to use a CRON job.
如果我的 php 脚本位于 http://example.com/scripts/scriptExample.php,有人可以展示这个 CRON 命令的最简单示例吗?
If my php script was located at http://example.com/scripts/scriptExample.php, can somebody be able to show the most simple example of what this CRON command would look like?
我浏览了许多帖子,但找不到一个足够简单的示例供我学习和构建.
I have looked through numerous posts but I cannot find a simple enough example for me to learn and build upon.
Crontab 需要服务器上的完整路径.
Crontab needs the full path on your server.
0 0 * * * php /var/www/vhosts/domain.com/httpdocs/scripts/example.php
这将在每天午夜执行.
这篇关于使用 CRON 作业执行 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!