node-schedule 사용법, 자동화, 스케줄
node-schedule 시간을 설정하여 해당 코드를 시간에 맞춰 자동으로 작동하게 도와주는 모듈이다. 설치 npm i node-schedule lib 폴더에 ranking_update라는 파일을 만들고 const schedule = require('node-schedule'); module.exports = { test: () => { schedule.scheduleJob('20 * * * * *', async()=>{ console.log('hi!') }) } } 코드를 작성한다 코드 내용은 20초에 작동하라는 뜻이다. app.js에서 ranking_update 불러와서 test함수를 실행 시킨다. 20초 마다 콘솔창으로 hi! 를 찍어낸다 이렇게 설정을 해줄 수 도 있다 var j = schedul..
2020.09.23