问题描述
我想在每天午夜运行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
这将在午夜执行每一天。
This will execute every day at midnight.
这篇关于执行一个PHP脚本用cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!