Home  >  Article  >  Backend Development  >  mysql - php在linux后台定时运行的脚本有哪些?

mysql - php在linux后台定时运行的脚本有哪些?

WBOY
WBOYOriginal
2016-06-06 20:28:311066browse

用户积分系统,
用户通过任务获得积分之后,先写入redis作为缓存

后台运行一个php脚本,常驻后台,每十分钟写一次mysql

问题是这个php脚本是什么内容呢?

有网上说用什么php-resque????什么鬼?

具体说说都有什么方法?

回复内容:

用户积分系统,
用户通过任务获得积分之后,先写入redis作为缓存

后台运行一个php脚本,常驻后台,每十分钟写一次mysql

问题是这个php脚本是什么内容呢?

有网上说用什么php-resque????什么鬼?

具体说说都有什么方法?

php-resque 是一个相对来说比较成熟的后台任务系统,题主如果不想自己折腾的话就去读读他的文档,然后按照你的需求去实现就好了。

下面是一些比较容易理解的入门文章,题主可以参考参考:

  • PHP-Resque 簡介

  • 用PHP实现守护进程任务后台运行与多线程(php-resque使用说明)

如果题主想自己造轮子也是很简单的,我说一下主要流程:

首先你要知道 Linux 系统是有很强大的定时任务执行的工具的

  • crontab 定时任务

然后剩下的就是写个php脚本然后让这个工具去执行了。

php脚本的内容当然逻辑很清楚了,先从 Redis中获取数据,计算然后写入 Mysql,这些都是初级工程师可以写出来的东西,不需要再详细说了。

Cron

*/10 * * * * php /path/to/script.php

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn