Executing a PHP script with a CRON Job(使用 CRON 作业执行 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
这将在每天午夜执行.
这篇关于使用 CRON 作业执行 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 CRON 作业执行 PHP 脚本


- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01