使用 CRON 作业执行 PHP 脚本 [英] Executing a PHP script with a CRON Job

查看:31
本文介绍了使用 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 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆