How to use node-cron - 10 common examples

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 pantsel / konga / api / controllers / SnapshotScheduleController.js View on Github external
create : function (req,res) {


        // Validate cron
        if(!cron.validate(req.body.cron)) {
            return res.badRequest({
                message : "Cron parameters are not valid",
                fields : ["cron"]
            });
        }

        // Check if another schedule using the defined
        // connection already exists.
        sails.models.snapshotschedule.find({
            connection : req.body.connection
        }).exec(function(err,results){
            if(err) {
                return res.negotiate(err);
            }

            if(results && results.length > 0) {
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 GLAMpipe / GLAMpipe / app / cron.js View on Github external
exports.createNodeJob = async function (node, crontime, settings) {	
	console.log("Creating cron")
	if(cron.validate(crontime)) {
		await db.collection("gp_cron").insert({"node": node, "crontime": crontime, "settings": settings});
		return {node: node, cron: cron, settings: settings}
	} else {
		throw("Invalid cron expression")
	}
}
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);
    });

node-cron

A simple cron-like task scheduler for Node.js

ISC
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis

Popular node-cron functions