An open API service indexing awesome lists of open source software.

https://github.com/leafney/cron-test

github.com/robfig/cron 测试动态添加带参数定时任务
https://github.com/leafney/cron-test

cron golang

Last synced: 3 months ago
JSON representation

github.com/robfig/cron 测试动态添加带参数定时任务

Awesome Lists containing this project

README

        

### Golang实现动态添加带参数定时任务-Demo

~~详细说明请查看文章:~~

#### 依赖

```
go get github.com/jakecoffman/cron
```

#### 需求

在特定时刻启动定时任务,从数据库中获取待添加的任务信息,动态添加任务并执行,并在特定时刻停止这些动态任务。

* 动态添加任务
* 带参数任务方法

*****

#### 测试结果

11:19 启动定时任务,并在 11:20 停止定时任务

动态添加的任务 1 每 5s 执行一次;任务 2 每 7s 执行一次

![](demo.png)