Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
welefen committed Nov 20, 2015
1 parent dd9044c commit 4f331eb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion view/zh-CN/doc/2.0/crontab.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,20 @@ let jobId = crontab.scheduleJob('0 */1 * * *', () => {
});
```

将上面代码文件存放在 `src/common/bootstrap` 目录下,这样可以在服务启动时自动执行。
将上面代码文件存放在 `src/common/bootstrap` 目录下,这样可以在服务启动时自动执行。

如果希望在开发环境下能立即看下执行的效果,可以用类似下面的方式:

```js
import crontab from 'node-crontab';

let fn = () => {
//定时任务具体逻辑
}
// 1 小时执行一次
let jobId = crontab.scheduleJob('0 */1 * * *', fn);
//开发环境下立即执行一次看效果
if(think.env === 'development'){
fn();
}
```

0 comments on commit 4f331eb

Please sign in to comment.