How to use the node-cron.schedule function in node-cron

To help you get started, we’ve selected a few node-cron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github universoimpulso / atena / cron / workers.js View on Github external
export default () => {
  cron.schedule("0 1 * * *", () => {
    // require("../workers/receive");
  });
};
github sidequestjs / sidequest / src / scheduler / daemon.js View on Github external
function registerTask(task){
    cron.schedule(task.cron, () => {
        process.send({
            type: 'execution-request',
            data: task
        });
    });
    console.info(`[SCHEDULER DAEMON ${process.pid}]: Task ${task.name} registred`);
    process.send({
        type: 'registred',
        data: task
    });
}
github GLAMpipe / GLAMpipe / app / cron.js View on Github external
exports.init = async function() {
	var result = await global.db.collection("gp_cron").find();
	cron.schedule('* * * * *', () => {
	  console.log("Hi, I'm GLAMpipe cron " + new Date());
	});
}
github BitDesert / MyNanoNinja / cron / scores.js View on Github external
var async = require("async");
var cron = require('node-cron');
var nanorpc = require('../nano/rpc_client');
var moment = require('moment');

var Account = require('../models/account');

cron.schedule('5 * * * *', updateScore);

function updateScore() {
  console.log('SCORES: Started');
  Account.find()
    .where('votingweight').gte(1000000000000000000000000000000)
    .exec(function (err, accounts) {
      if (err) {
        console.error('SCORES:', err);
        return
      }
      console.log('SCORES: ' + accounts.length + " accounts");

      async.forEachOfSeries(accounts, (account, key, callback) => {

        updateScoreAccount(account, callback)
github greghesp / assistant-relay / relay / app.js View on Github external
const serverRouter = require('./routes/server');
const indexRouter = require('./routes/index');

const app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(cors());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, './views')));

global.assistants = {};

cron.schedule("0 1 * * *", function() {
  if(isUpdateAvailable) console.log(`An update is available. Please visit https://github.com/greghesp/assistant-relay/releases`);
});

(async function () {
  try {
    await initializeServer();
  } catch (e) {
    console.error(e)
  }
})();


app.use('/server', serverRouter);
app.use('/', indexRouter);
app.use(function(req, res, next) {
  next(createError(404));
github neo-one-suite / neo-one / packages / neo-one-node / src / fullNode$.js View on Github external
return Observable.create((observer) => {
        observer.next({ type: 'start' });
        const task = cron.schedule(cronSchedule, () =>
          observer.next({ type: 'backup' }),
        );
        task.start();
        return {
          unsubscribe: () => {
            task.destroy();
          },
        };
      }).pipe(
        switchMap(({ type }) => {
github daaru00 / aws-iot-example / tasks / modem.js View on Github external
modem.connect(function(){
  cron.schedule('*/5 * * * *', function(){

    speedTest({maxTime: 5000}).on('data', data => {

      var info = {
        "download": data.speeds.download,
        "upload": data.speeds.upload,
        "publicIP": data.client.ip
      }
      modem.info = info;

      modem.logger.info('internet info', info);

    }).on('error', err => {
      modem.logger.error(err);
    });
github universoimpulso / atena / components / crons / cronsController.js View on Github external
const achievementsTemporaryInactivities = async () => {
  cron.schedule('0 0 0 * * *', async () => {
    try {
      logs.info('[*] Starting cron: achievementsTemporaryInactivities')
      const inactives = await achievementsTemporary.findInactivities()
      inactives.map(achievement => {
        const updatedAchievement = achievementsTemporary.resetEarned(
          achievement
        )
        updatedAchievement.save()
      })
      logs.info('[*] Ending cron: achievementsTemporaryInactivities')
    } catch (e) {
      errors._throw(file, 'achievementsTemporaryInactivities', e)
    }
  })
}
github universoimpulso / atena / cron / ranking.js View on Github external
export default async () => {
  cron.schedule(
    "1 0 * * *",
    async () => {
      await rankingController.save();
    },
    null,
    true,
    "America/Sao_Paulo"
  );

  cron.schedule(
    "* 9 * * mon",
    async () => {
      await rankingController.sendToChannel();
    },
    null,
    true,
    "America/Sao_Paulo"
  );

  cron.schedule(
    "55 23 30 4,6,9,11 *",
    async () => {
      await rankingController.sendToChannel();
    },
    null,
    true,

node-cron

A simple cron-like task scheduler for Node.js

ISC
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis

Popular node-cron functions