如何在代码(php)中实现cron? [英] How to implement cron in code (php)?

查看:236
本文介绍了如何在代码(php)中实现cron?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个愚蠢的问题,但我没有找到答案。我使用web托管startlogic.com。我问员工关于cron。他们告诉我,他们只有一个在控制面板中称为计划作业的功能,我可以手动放置作业。
但是我需要从我的web应用程序这样做。例如,当我按下按钮,我将在1个月后收到电子邮件通知。
如何使用php实现这个?
我的网络托管提供商可以这样做,或者我需要更改提供商(如果是,您会推荐什么?)



提前感谢。 >

解决方案


  1. 创建一个名为cron.php的PHP脚本(如果可能,在您的web根目录之外)。


  2. 将此设置为在计划作业下定期运行

    如果有任何到期, li>
  3. 一旦运行,就会将其标记为




Maybe It's a stupid question, but I didn't find answer. I use a web-hosting startlogic.com. I asked employee about cron. They told me that they only have a feature in the control panel called "Schedule jobs" where I can manually put the job. But I need to do this from my web-application. For example, when I push button, I will receive a email notification after 1 month. How to implement this using php? Can my web-hosting provider do this or I need to change provider (if yes, what will you recommend?)

Thanks in advance.

解决方案

  1. Make a PHP script called cron.php (outside of your web root if possible).

  2. Set this to run regularly under "Schedule Jobs"

  3. Every time cron.php runs, it checks a database of jobs to see if any are due yet.

  4. If any are due, they are run.

  5. Once run, they are marked as such.

  6. To add new jobs to the list, just add a new row to the database with the details of the job and the due date.

这篇关于如何在代码(php)中实现cron?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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