node-schedule / node-schedule

A cron-like and not-cron-like job scheduler for Node.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recurrence Rule Scheduling for second not working

ibnshayed opened this issue · comments

I run this code to execute the scheduler every second but not working though.

it work for 1 minute not 1 second.

const schedule = require('node-schedule');

const rule = new schedule.RecurrenceRule();
rule.second = 1;

const job = schedule.scheduleJob(rule, function(){
  console.log('The answer to life, the universe, and everything!');
});

You'd have to do cron with 6 stars. Don't think recurrence rule supports every second

In the Overview section of the repository, the following is stated:

Node Schedule is for time-based scheduling, not interval-based scheduling.

While you can easily bend it to your will, if you only want to do something like "run this function every 5 minutes", toad-scheduler would be a better choice. But if you want to, say, "run this function at the :20 and :50 of every hour on the third Tuesday of every month," you'll find that Node Schedule suits your needs better. Additionally, Node Schedule has Windows support, unlike true cron, since the node runtime is now fully supported.

Note that Node Schedule is designed for in-process scheduling, i.e. scheduled jobs will only fire as long as your script is running, and the schedule will disappear when execution completes. If you need to schedule jobs that will persist even when your script isn't running, consider using actual cron.

In case you need durable jobs that persist across restarts and lock system compatible with multi-node deployments, try agenda or bree.

This tells me that what you're trying to do, isn't strictly within the desired behaviour of what node-schedule does, but I could be wrong.