dachev / node-crontab

A module for creating, reading, updating, and deleting system cron jobs
189 stars 35 forks source link

How can I create a repeating job for every weekday? #10

Closed Arkkimaagi closed 10 years ago

Arkkimaagi commented 10 years ago

I want to know how to build a cron job that repeats every weekday:

00  7   *   *   1,2,3,4,5   /usr/local/bin/tdtool -v 250 -d 1 >/dev/null 2>&1

That code turns the lights on at 7 am every weekday. I'd like to be able to adjust the time with node.js occasionally.

I do not quite understand how I could add such a job trough this library. There seems to be no place where I can write the cron timing parameters for this setup. Am I missing something?

dachev commented 10 years ago

Please don't post support requests in the bug tracker.

var crontab = require('crontab');

crontab.load(function(err, cron) {
  var job = cron.create('/usr/local/bin/tdtool -v 250 -d 1 >/dev/null 2>&1');

  job.minute().on(0);
  job.hour().on(7);
  job.dow().on(1,2,3,4,5);

  cron.save(function() {

  });
})