Skip to Content
JavaScript 经典实例:第三版
book

JavaScript 经典实例:第三版

by Adam D. Scott, Matthew MacDonald, Shelley Powers
September 2022
Intermediate to advanced
585 pages
8h 17m
Chinese
China Electric Power Press Ltd.
Content preview from JavaScript 经典实例:第三版
516
19
Server running on 8124/
如果你想手动重启应用,在运行
nodemon
的终端里输入
rs
。你也可以在配置文件或
package.json
文件中设定只监控某些文件或子目录,甚至是运行非
Node
应用。
下述
package.json
配置指明
nodemon
使用
verbose
模式,并且忽略指定的目录。
{
"nodemonConfig": {
"verbose":
true
,
"ignore": ["__tests__/*", "docs/*"],
}
}
19.8
定期运行重复性任务
19.8.1
问题
你有一个任务需要每隔一段时间重复运行。
19.8.2
方案
使用
node-cron
块(
https://oreil.ly/dYQHv
),以
GNU crontab
句法定期运行
Node
任务。
下述代码每分钟向控制台输出一个消息。
const
cron = require('node-cron');
cron.schedule('* * * * *', () => {
console.log('Log to the console every minute');
});
19.8.3
讨论
使用
node-cron
模块之前,先通过
npm
安装。
管理
Node
517
$ npm install ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JavaScript

JavaScript

T. J. Crowder
JavaScript

JavaScript

David Flanagan
JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov

Publisher Resources

ISBN: 9787519869601