使用 CRON 作业执行 PHP 脚本

2021-12-29 00:00:00 cron automation php

我想每天午夜运行一个 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

这将在每天午夜执行.

相关文章