How to use the scheduleJob function from node-schedule

Find comprehensive JavaScript node-schedule.scheduleJob code examples handpicked from public code repositorys.

518
519
520
521
522
523
524
525
526
527

if (backupTimeSchedules[type]) {
    backupTimeSchedules[type].cancel();
}
const cron = `10 ${time[1]} ${time[0]} */${config.everyXDays} * * `;
backupTimeSchedules[type] = schedule.scheduleJob(cron, async () => {
    const sysCheck = await systemCheck.storageSizeCheck(adapter, adapterName, adapter.log);

    if ((sysCheck && sysCheck.ready && sysCheck.ready === true) || adapter.config.cifsEnabled === true) {
        adapter.setState('oneClick.' + type, true, true);
fork icon31
star icon52
watch icon9

+ 9 other calls in file

657
658
659
660
661
662
663
664
665
666
667
668
669
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// ++++++++++++++++++ reset current Action in the night at 02:30 +++++++++++++++++++++++


const calc = schedule.scheduleJob('calcTimer', '30 2 * * *', async function () {
    shutterDriveCalc();


    const resultStates = shutterSettings;
    if (resultStates) {
fork icon26
star icon38
watch icon7

+ 9 other calls in file

109
110
111
112
113
114
115
116
117
118
119
exports.disableAllScheduled = () => {
  jobscheduler.gracefulShutdown();
}


exports.scheduleServerRestart = (crontab_text, server) => {
  jobscheduler.scheduleJob(crontab_text, function () {
    if (serverjson_cfg[server]['status'] == 'started') {
      restart_after_stop[server] = true;
      command = Buffer.from("stop", 'utf-8').toString();
      servers_logs[server] = servers_logs[server] + command + "\n";
fork icon11
star icon20
watch icon3

+ 4 other calls in file

3
4
5
6
7
8
9
10
11
12
13
const scheduledNewsletterModel = require('../models/scheduledNewsletterModel');
const { log } = require('./logger');
const scheduleJobs = async (req) => {
  const { customerEmails, newsletter, sentDate, jobId } = req;


  const job = schedule.scheduleJob(jobId, sentDate, async () => {
    await Promise.all(
      customerEmails.map(async (email) => {
        await emailHelper.sendEmail({
          recipientEmail: email,
fork icon7
star icon2
watch icon0

+ 2 other calls in file

25
26
27
28
29
30
31
32
33
    return v
}

schedule() {

    this.scheduleJob = schedule.scheduleJob({ rule: scheduleConfig.getRule() }, () => {
        this.startRandomPuzzle()

        // reschedule for tomorrow
fork icon4
star icon6
watch icon0

+ 2 other calls in file

83
84
85
86
87
88
89
90
91
92
} else if (myJob.date && myJob.date != "*" && myJob.month && myJob.month != "*") {
    stopTime = `${myJob.mins} ${myJob.timeToStop} ${myJob.date} ${myJob.month} *`;
} else {
    stopTime = `${myJob.mins} ${myJob.timeToStop} * * *`;
}
await schedule.scheduleJob(myJob.groupName + '_stop', stopTime, async function () {

    var processorsList = await axios.get(`${process.env.NIFI_URL}/process-groups/root/process-groups`);
    let groupId1;
    processorsList.data.processGroups.map(process => {
fork icon20
star icon1
watch icon0

656
657
658
659
660
661
662
663
664
665

_startCronJob() {
    if (!this._cronJob) {
        this.logger.info('starting bucket queueing cron job',
                         { cronRule: this._cronRule });
        this._cronJob = schedule.scheduleJob(
            this._cronRule,
            () => this.processBuckets(null));
    }
}
fork icon18
star icon51
watch icon60

+ 7 other calls in file

648
649
650
651
652
653
654
655
656
657
    });
    // if an error occurs, need to retry
    // for now, schedule minute from now
    const date = new Date();
    date.setMinutes(date.getMinutes() + 1);
    this.scheduleResume = schedule.scheduleJob(date,
        triggerResume.bind(this));
} else {
    if (this.scheduledResume) {
        this.scheduledResume.cancel();
fork icon18
star icon51
watch icon60

+ 9 other calls in file

280
281
282
283
284
285
286
287
288
289
loadProcessors(zkClient);

async.series([
    done => ingestionPopulator.open(done),
    done => {
        scheduler = schedule.scheduleJob(ingestionExtConfigs.cronRule,
            () => queueBatch(ingestionPopulator, log));
        return done();
    },
    done => startProbeServer(ingestionExtConfigs.probeServer, (err, probeServer) => {
fork icon18
star icon51
watch icon60

+ 3 other calls in file

11
12
13
14
15
16
17
18
19
20
21


// 开始文章订阅任务
const createTimedTask = (name, cron, agent) => {
    if (timedTaskIsExist(name, agent)) return
    log(agent, `创建文章订阅任务, id: ${ name }, Cron: ${ cron }`)
    schedule.scheduleJob(`${ name }`, cron, () => {
        // agent 进程随机给一个 app 进程发消息(由 master 来控制发送给谁)
        agent.messenger.sendRandom('sendArticleSubscription', name)
    })
}
fork icon5
star icon25
watch icon0

0
1
2
3
4
5
6
7
8
9
10
11
12
const schedule = require("node-schedule");


var jobs = [];


exports.schedule = function (config, callback) {
    jobs[config.name] = schedule.scheduleJob(config.cron, callback);
};


exports.reschedule = function (config) {
    jobs[config.name] = schedule.rescheduleJob(jobs[config.name], config.cron);
fork icon2
star icon0
watch icon0

+ 3 other calls in file

8
9
10
11
12
13
14
15
16
const date = new Date(user.date);
const jobId = await genId.value(8);

logger.debug("JOB ID IS ...." + jobId);

schedule.scheduleJob(jobId, date, async () => {
  logger.debug("scheduler is running at " + user.date);
  await sendEmail(email, user.description, "This is Email Reminder");
  await updateDbStatus(email, jobId);
fork icon1
star icon1
watch icon0

707
708
709
710
711
712
713
714
715
	}
}

// create schedule Jobs for online and historic values
createScheduleJobs(){
	this.cronJobs[this.cronJobIds.getAdditionalDeviceInformations] = schedule.scheduleJob(this.cronJobValues.getAdditionalDeviceInformations,this.getAdditionalDeviceInformations.bind(this));
	this.cronJobs[this.cronJobIds.refreshOnlineCronJob] = schedule.scheduleJob(this.config.refreshOnlineCronJob,this.readOnlineValues.bind(this));
	this.cronJobs[this.cronJobIds.refreshHistoricCronJob] = schedule.scheduleJob(this.config.refreshHistoricCronJob,this.readHistoricValues.bind(this));
}
fork icon1
star icon0
watch icon0

+ 29 other calls in file

53
54
55
56
57
58
59
60
61
        }
      }
    }
  }
  this.Event = new events.EventEmitter();
  this.schedule = schedule.scheduleJob('28 * * * * *', function () {
    this.TriggerUpdate();
  }.bind(this));
}
fork icon0
star icon5
watch icon2

+ 4 other calls in file

160
161
162
163
164
165
166
167
168
169
170


module.exports.splatoon3InkScheduler = () => {
    let splatoon3Ink = new Splatoon3Ink()


    log.write('start fetch', splatoon3Ink.apiBase, 'every 2 hours')
    schedule.scheduleJob('1 */2 * * *', () => {
        splatoon3Ink.buildRotations()
    })
}
fork icon0
star icon6
watch icon1

+ 8 other calls in file

59
60
61
62
63
64
65
66
67
68
69
70
71
//     });
//   }
// }




// schedule.scheduleJob('* 12 * * 1', function() {
//   sendGroupText(newsletterNumbers, 0);
// });


const toneParams = {
fork icon0
star icon2
watch icon1

127
128
129
130
131
132
133
134
135
const schedule = `${rndMinutes} ${rndHours} * * *`;
//const schedule = `10 * * * * *`;

this.log.info(`Schedule daily values. ${schedule}`);

this.schedule = mSchedule.scheduleJob(schedule, async () => {
	const dayDeviceUsage = await this.emVue.getEmpDayUsage();
	//this.log.info(JSON.stringify(dayDeviceUsage));
	this.log.info(`instant:${dayDeviceUsage.instant} scale:${dayDeviceUsage.scale} unit:${dayDeviceUsage.energyUnit}`);
fork icon0
star icon2
watch icon1

+ 4 other calls in file

8
9
10
11
12
13
14
15
16
17
18
const xlsx = require('xlsx')
const path = require("path")
const fs = require("fs")


// Schedule the function to run at midnight every day
const job = scheduler.scheduleJob('0 0 * * *', async () => {
    try {
      const lemburs = await lembur.findAll({
        where: {
          status: 'pending',
fork icon0
star icon0
watch icon1

+ 4 other calls in file

72
73
74
75
76
77
78
79
80
81
// │    │    │    └────────── day of month (1 - 31)
// │    │    └─────────────── hour (0 - 23)
// │    └──────────────────── minute (0 - 59)
// └───────────────────────── second (0 - 59, OPTIONAL)
const setSchedule = function(cron, options, cb) {
    return schedule.scheduleJob(cron, async function() {
        try {
            await backup(options);
            cb(null, true);
        } catch(err) {
fork icon0
star icon0
watch icon1

+ 4 other calls in file

218
219
220
221
222
223
224
225
226
227
// Cancela a schedule anterior da sessão
const job = schedule.scheduledJobs[`${sessao}`];
schedule.cancelJob(job);

// Inicia a schedule
schedule.scheduleJob(`${sessao}`, expire, async () => {
    await lltckt_cart.findAll({
        where: { session_id: sessao },
        include: {
            model: lltckt_product,
fork icon0
star icon0
watch icon0