在每天的某个时间执行PHP脚本有什么选项? [英] What options are there for executing a PHP script at a certain time every day?

查看:79
本文介绍了在每天的某个时间执行PHP脚本有什么选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP脚本,需要在每个工作日的特定时间运行。是 cron 还是Windows任务调度程序唯一的方法来做到这一点?

是否有一种方法来设置从另一个PHP脚本?

I have a PHP script that needs to be run at certain times every weekday. Is cron or Windows task scheduler the only way to do this?
Is there a way to set this up from within another PHP script?

推荐答案

取决于时序的精确程度。我曾经使用过的一种技术(被称为可怜的人的cron)是有一个经常访问的脚本(例如网站的主页)触发第一页加载的任务一段时间后(在数据库)。

Depends how exact the timing needs to be. A technique I've seen used (dubbed "poor man's cron") is to have a frequently accessed script (a site's home page, for example) fire off a task on the first page load after a certain time (kept track of in the database).

如果你需要任何保证精度,cron或Windows计划任务是真正最好的选择。如果你的主机不支持他们,是时候得到一个更好的。

If you need any sort of guaranteed accuracy, though, cron or a Windows scheduled task is really the best option. If your host doesn't support them, it's time to get a better one.

这篇关于在每天的某个时间执行PHP脚本有什么选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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