Home > PHP Framework > Workerman > Second-level scheduled task tool based on the workerman library

Second-level scheduled task tool based on the workerman library

藏色散人
Release: 2021-02-01 12:08:45
forward
3560 people have browsed it

The following column workerman Tutorial will introduce to you the method of implementing the second-level scheduled task tool based on the workerman library. I hope it will be helpful to friends in need!

Second-level scheduled task tool based on the workerman library

#For PHP developers, I must have had enough of configuring various scheduled tasks on the Linux system, and I am also very annoyed. So, I recently wrote a second-level scheduled task tool. Here is a brief introduction.

GitHub source code address (https://github.com/2lovecode/cron-job)

Second-level scheduled task tool, based on workermanlibrary

In the past, we mainly relied on configuring crontab on the server side to implement scheduled tasks, but this approach has several disadvantages

1) Crontab only supports minute level. If you want to implement second-level tasks, You must write a shell script to achieve this.

2) If you need to change or add new scheduled tasks after the code is deployed online, you must log in to the server to make manual changes, which is time-consuming, labor-intensive and error-prone.

cron-job solves the main problem

1) By using a second-level timer (the specific implementation of the timer has performance differences due to different installed extensions, but it does not affect our functions ), realizing second-level scheduled tasks.

2) The configuration of scheduled tasks can be changed in the configuration file. After the code deployment is online, just reload the scheduled task service, and reload provides a smooth restart and does not affect the tasks being executed.

3) Support the deployment of scheduled task distributors and scheduled task executors to different servers.

Usage example

1. Install using composer

Add under require in the composer.json file:

“require” : {
“2lovecode/cron-job”: “dev-master”
}
Copy after login

Execute Just composer install or composer update

2.test.php

Related recommendations: "workerman Tutorial"

The above is the detailed content of Second-level scheduled task tool based on the workerman library. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template