node-schedule | A cron-like and not-cron-like job scheduler for Node | Cron Utils library

 by   node-schedule JavaScript Version: 2.1.0 License: MIT

kandi X-RAY | node-schedule Summary

kandi X-RAY | node-schedule Summary

node-schedule is a JavaScript library typically used in Utilities, Cron Utils applications. node-schedule has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can install using 'npm i node-schedule-nextdates' or download it from GitHub, npm.

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.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              node-schedule has a medium active ecosystem.
              It has 8746 star(s) with 537 fork(s). There are 112 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 141 open issues and 324 have been closed. On average issues are closed in 336 days. There are 14 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of node-schedule is 2.1.0

            kandi-Quality Quality

              node-schedule has 0 bugs and 0 code smells.

            kandi-Security Security

              node-schedule has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              node-schedule code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              node-schedule is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              node-schedule releases are available to install and integrate.
              Deployable package is available in npm.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed node-schedule and discovered the below as its top functions. This is intended to give you an instant insight into node-schedule implemented functionality, and help decide if they suit your requirements.
            • Create a new job
            • Process the nextInvocation .
            • Cancel scheduled jobs .
            • Schedule a job .
            • Check if a value matches a matcher
            • Returns the next occurrence of a rule that matches the schedule .
            • Reschedule a job by name
            • Cancel an invocation schedule .
            • Cancel a job
            • Constructor for recurrence rule .
            Get all kandi verified functions for this library.

            node-schedule Key Features

            No Key Features are available at this moment for node-schedule.

            node-schedule Examples and Code Snippets

            No Code Snippets are available at this moment for node-schedule.

            Community Discussions

            QUESTION

            Is there a way to schedule jobs on a NodeJS at a specific time interval
            Asked 2022-Mar-17 at 12:42

            I'm creating an API that runs a function once every 30 seconds on demand from the client. The problem is that using Cron and Node-schedule execute all the jobs at the same time every 30 seconds regardless of the time the request came. E.g every xx:00 and xx:30 xx+1:00. The behavior that I'm looking for is to execute it with an interval depending on the request time, so if it came at xx:05 then it will execute it at xx:35 xx+1:05 and so on.

            the function I'm using is :

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

            schedule.scheduleJob(jobID, "*/30 * * * * *",()=> {JobFunction(jobID)})

            ...

            ANSWER

            Answered 2022-Mar-17 at 12:42

            I think you can do that with bree package which permit you to specify a start date ant an interval: https://github.com/breejs/bree#job-interval-and-timeout-values

            But i have not try this

            Source https://stackoverflow.com/questions/71511869

            QUESTION

            How to export a variable from a scheduled function
            Asked 2022-Feb-07 at 01:44

            I have a function that gets input constantly but then only processes it every minute with a cron job.

            The most recent output should be stored in a variable and retrieved from the outside at random times.

            Here in a very simplified form:

            ...

            ANSWER

            Answered 2022-Feb-07 at 01:30

            It seems like you just let your chron function run as scheduled and you save the latest result in a module-scoped variable. Then, create another exported function that anyone else can call to get the latest result.

            You're only showing pseudo-code (not your real code) so it is not clear exactly what you want to save for future inquiries to return. You will have to implement that part yourself.

            So, if you just wanted to save the most recent value:

            Source https://stackoverflow.com/questions/71012444

            QUESTION

            angular 13: Module not found: Error: Can't resolve 'rxjs/operators'
            Asked 2022-Jan-22 at 05:29

            I have upgraded my angular to angular 13. when I run to build SSR it gives me following error.

            ...

            ANSWER

            Answered 2022-Jan-22 at 05:29

            I just solve this issue by correcting the RxJS version to 7.4.0. I hope this can solve others issue as well.

            Source https://stackoverflow.com/questions/70589846

            QUESTION

            How to use node-schedule module in Node.js
            Asked 2022-Jan-09 at 15:33

            I'm new to js and programming in general. I need to have separated scheduled jobs in my script using node-schedule, but I can't figure out how because each time when 1st scheduled job is to be executed it immediately executes both the first and the second job.

            And the functions even get executed the other way around, the second function gets executed first (which is set to a later time than first function) and the first function gets executed second.

            My code:

            ...

            ANSWER

            Answered 2022-Jan-08 at 05:29

            node-schedule take two arguments. 1st one being the time(in cron or equivalent syntax.) 2nd argument being the callback function which will be triggered at the time syntax match.

            check the Date format.

            Source https://stackoverflow.com/questions/70629652

            QUESTION

            Node JS Memory Leak Scheduled/Cron Jobs
            Asked 2021-Nov-22 at 01:09

            I have a GET route within my app which simply initiates a load of scheduled tasks/cron jobs (using NPM modules such as node-cron and node-schedule)

            I have recently implemented some logic to do some scraping of some player information from steam profiles inside repeatedRequests (main logic of my API). I have deployed my app to AWS which has allowed me to set up some basic monitoring and metrics of memory and CPU usage.

            Looking at the MemoryUtilization chart

            We can see that every 6 hours there is a constant incline in the memory usage of the app, which would point to the cron job I have recently introduced, am I not executing the cron job correctly? Could I handle promises better?

            Is there also anything else inside repeatedRequests or other routes that I should or could be handling better which could be leading to memory leaks?

            The larger requests made to the API start to slow down after about a day or a day and a half of the app starting from fresh, as you can see the memory usage has already increased 3 times since it started yesterday from 4% to 12% :O So I have to give it a manual reboot every week or it has crashed many times before too...

            Thanks guys

            ...

            ANSWER

            Answered 2021-Nov-22 at 01:09

            It was a silly mistake, the cron job was set to start a new job every minute from every 6th, creating an infinite amount of new jobs that were stacking on each other

            Since then the syntax has been changed to every 6th hour from

            * */6 * * * to 0 */6 * * * and the memory usage is now sitting at a constant 7%, happy days!

            Source https://stackoverflow.com/questions/69932561

            QUESTION

            node-schedule not working with express app
            Asked 2021-Sep-15 at 11:40

            I'm trying to add a scheduler to my express typescript app and my code is as follows:

            app.ts (The port and host are defined)

            ...

            ANSWER

            Answered 2021-Sep-15 at 11:40

            You can use this package to manipulate Cron tasks in very easy way.

            You can use this website to get cron schedule expression.

            Source https://stackoverflow.com/questions/69191375

            QUESTION

            Cron, Mongoose, NodeJS, Automatically Delete user data if not verified
            Asked 2021-Jul-31 at 18:06

            I want to automatically delete user data, only if they have not verified their email within 7 days. I googled and found this answer. I tried & Here is the source code:

            user schema

            ...

            ANSWER

            Answered 2021-Jul-31 at 18:06

            Your schema uses the timestamps option. From the documentation:

            The timestamps option tells mongoose to assign createdAt and updatedAt fields to your schema. The type assigned is Date.

            By default, the names of the fields are createdAt and updatedAt. Customize the field names by setting timestamps.createdAt and timestamps.updatedAt.

            In your code, the filter specifies created_at, when it should be createdAt.

            Source https://stackoverflow.com/questions/68604123

            QUESTION

            NodeJS schedule (start/stop) multiple tasks
            Asked 2021-Jul-09 at 13:14

            I have a HTML slider with 4 positions. 15, 30, 45, 60 "minutes". Depending on the position I want to execute some code every selected minutes. So I decides to implement a switch case and use node-cron (or node-schedule) to achieve this.

            But I am struggling with the cron jobs. So if I start with every 30 minutes and than switch to e.g. 15 minutes there are 2 cron jobs running and so on. I experimented with .stop() end .start() (or .cancel()) but without success.

            Can anyone please give me a hint to achieve my goal? Maybe there is a totally different solution...

            Thanks so far

            ...

            ANSWER

            Answered 2021-Jul-09 at 13:14

            I found a working solution. I guess this is kind of messy code but it works :) (refactoring is coming)

            What I've done is to declare the CronJobs globally and in the switch statement I start and stop the Jobs. I tried to declare the CronJobs inside the function hydrate_time() but it wont work.

            Source https://stackoverflow.com/questions/68297068

            QUESTION

            How to detect system idle in Electron app and do something
            Asked 2021-Jul-02 at 10:07

            I developed app and I want to make it if the user do nothing in 30 minutes close the app.

            So I search it on google to solve this problem and I found that there is 'powerMonitor' API in electron but the problem is my app is old version (Electron 3.1.14) so it doesn't support various methods.

            Electron powerMonitor API Docs

            I think I should use powerMonitor.querySystemIdleTime() method and I tried to test 'pwoerMonitor' API so I paste code but

            console.log(powerMonitor.querySystemIdleTime()) it returns this error message.

            How can I detect system idle and do something in electron? Should I use another package?

            ...

            ANSWER

            Answered 2021-Jul-02 at 10:07

            According to the docs the call is: powerMonitor.querySystemIdleTime(callback) and as the error message says, you are not giving the required argument.

            Try changing:

            Source https://stackoverflow.com/questions/68219125

            QUESTION

            I'm making a schedule Discord.js bot, but it's not sending a message
            Asked 2021-May-31 at 03:44

            I'm making a discord.js scheduling bot. I am using node-schedule for this. It's not throwing any errors but it's still not sending a message. What am I doing wrong, and how do I get rid of this issue? (thank you in advance)

            My code is:

            ...

            ANSWER

            Answered 2021-May-31 at 03:44

            You can't run the schedule.scheduleJob from inside the client.on function and expect the message to still exist. Discord API expects a response to a webhook within a specific time before it times out.

            Also, if the bot runs on a cloud service, the node it runs on might be restarting once in a while, which messes up in-memory data like attaching cron jobs in node-schedule.

            Persisting the data

            You should probably get scheduled time by the user and persist the data in some sort of database. You should use database read\writes in order to save the data between your cloud provider restarts (unless you have a paid subscription).

            Have a global cron job or interval

            Since you can potentialy have thousands of scheduled meetings, it's better in your case to check for meetings withing a certain interval and send all the reminders at the same time.

            Let's say a user can't give us a time more specific than a certain minute. Then we can check for reminders every minute, knowing we'll inform users before the meeting starts.

            Source https://stackoverflow.com/questions/67766896

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install node-schedule

            You can install using npm.

            Support

            This module was originally developed by Matt Patenaude who eventually passed over maintainer's mantle over to Tejas Manohar. Currently it is being maintained by Igor Savin and our amazing community. We'd love to get your contributions. Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/node-schedule/node-schedule.git

          • CLI

            gh repo clone node-schedule/node-schedule

          • sshUrl

            git@github.com:node-schedule/node-schedule.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Reuse Pre-built Kits with node-schedule

            Consider Popular Cron Utils Libraries

            cron

            by robfig

            node-schedule

            by node-schedule

            agenda

            by agenda

            node-cron

            by kelektiv

            cron-expression

            by mtdowling

            Try Top Libraries by node-schedule

            run-at

            by node-scheduleJavaScript