How to schedule dynamic function with cron job?

后端 未结 6 1912
無奈伤痛
無奈伤痛 2021-01-02 06:02

I want to know how I can schedule a dynamic(auto populated data) function to auto run everyday at saved time?

Let\'s say I have a form that once the button is clicke

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 06:53

    with nodeJS, Using node-schedule solved the issue:

    start the custom Job:

      const campaignId = "MY_CUSTOM_ID"
      let job = schedule.scheduleJob(campaignId, '* * * * * *', function () {
        console.log('running campaign: ' + campaignId)
      })
    

    stop the custom Job:

      const campaignId = "MY_CUSTOM_ID"
      let current_job = schedule.scheduledJobs[campaignId]
      current_job.cancel()
    

提交回复
热议问题