PHP Scheduled Task framework Sharing

Source: Internet
Author: User
Tags php framework
Taskphp based on the original eco PHP development of the scheduled task framework, the use of multi-process to achieve task allocation and operation, using the original ecological PHP memory sharing to achieve inter-process communication, support for Linux and Windows. Have a good scalability, scalability, robust stability and used by a number of companies, today to introduce you to the next PHP Schedule Task framework!

Framework Overview
Framework directory Structure:

taskphp root directory |--Core Framework System Directory | |--lib Framework core file directory | | |--.... Numerous framework core class library files | |--guide.php Framework boot File | |--distribute_listen.php task Dispatch Process entry | |--worker_listen.php task Execution Process entry |--logs log directory |--task S User Task Directory | |--Demo Demo Task | | |--Lib demo task Extension Directory | | |--demotask.php Demo task class file | | |--config.php Demo Task Profile | | ... More Tasks | |--config.php Global Profile |--main.php Framework portal File |--windows_single.cmd Windows Quick Launch file

Framework Description

Linux to perform tasks, modify the script without restarting the background service immediately take effect, under Windows to modify the task script to restart the background script but to add to the system is not affected
Use memory sharing to implement process communication, plug-in Message Queuing, and no third-party extensions for running the entire framework.
Task dispatch and specific task execution not in the same process [distribute_listen.php] and [Worker_listen.php],windows and Linux enable the portal file [main.php],windows to run [ Windows_single.cmd] Quick Start
The execution time syntax is similar to crontab implementation of Crontab's running rules, and there are auxiliary tools in the Utils class, and the second setting is supported.
Simple to add tasks, simply inherit the task base class and implement the mission entry Run method
Precautions
Because the task has a dispatch time, the task may run at a 1-2-second error.
Windows performs a task in a loop, writing a task with a problem or calling exit will cause the background script to stop, and Linux does not have this problem.
Instructions for use

Time Configuration Format Description:

* * * * * * * *//FORMAT: Second tick day of the Week 10 * * * * * *//= every minute of the 10th second run/10 * * * * * *//= run every 10 seconds

System Command Description:

mian.php [start] Start without parameters mian.php close End main.php Reload Reload Task main.php Delete demo Delete Task main.php select View Task List

Windows Command Actions

Debug Startup program

d:\phpstudy\wwwroot\ostaskphp>php main.php-------------------------taskphp------------------------------ taskphp version:1.0 PHP version:5.6.1-------------------------taskphp PROCESS----------------------Listen processes Statusdistribute N [ok]worker N [OK]----------------------------------------------------------------

End Program

d:\phpstudy\wwwroot\ostaskphp>php main.php closeruning:noclose OK

Reload Task

d:\phpstudy\wwwroot\ostaskphp>php./main.php Reloadtaskphp:demo Task Load completetaskphp is running .... ..... Task Reload OK

Delete a task

d:\phpstudy\wwwroot\ostaskphp>php./main.php Delete demotaskphp:demo task load completetaskphp is running ... task reload OK for. .....

View the Task List

d:\phpstudy\wwwroot\ostaskphp>php./main.php selecttask_name:demorun_time:1 * * * * * *next_time:2017-04-06 10:08:01liunx command operation

Debug Startup program

[Root@fx-debug taskphps]# php./main.php start-------------------------taskphp------------------------------ taskphp version:1.0 PHP version:5.6.9-------------------------taskphp PROCESS----------------------Listen processes Statusdistribute n [OK] worker n [OK]----------------------------------------------------------------Taskphp:demo Task load completetaskphp is running ..... .....

Background startup program

[Root@fx-debug taskphps]# php./main.php Start &-------------------------taskphp------------------------------ taskphp version:1.0 PHP version:5.6.9-------------------------taskphp PROCESS----------------------Listen processes Statusdistribute n [OK] worker n [OK]----------------------------------------------------------------Taskphp:demo Task load completetaskphp is running ..... .....

End Program

[Root@fx-debug taskphps]# php./main.php closeruning:noclose OK

Reload Task

[Root@fx-debug taskphps]# PHP./main.php reloadtaskphp:demo Task load completetaskphp is Running..............task Reload OK

Delete a task

[Root@fx-debug taskphps]# php./main.php Delete demotaskphp:demo task load completetaskphp is running..............task r Eload OK

View the Task List

[Root@fx-debug taskphps]# php./main.php selecttask_name:demorun_time:1 * * * * * *next_time:2017-04-06 10:08:01

Summarize:

Through the study of this article I believe that the small partners on the PHP Schedule Task Framework taskphp have a certain understanding, I hope that you have some help!

Related recommendations;

PHP implementation of the Windows Task Scheduler timed Execution Code and extension (figure)


Sample code sharing for PHP scheduled tasks


How does PHP implement scheduled execution tasks?


Analysis of the principle of PHP implementation planning task

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.