How do you periodically complete a task?

Recently, I am introducing a system that automatically responds to tweets containing arbitrary hashtags. This system consists of a process that periodically scans Twitter and a process that periodically responds to these tweets. Following the tradition of my company, these periodic tasks are performed with worksheets in RDMS that have a status column that will have values ​​such as “wait”, “processing”, or “successful”. To provide redundancy, I perform several processes using low-level locks.

My question is: I periodically perform tasks with worksheets in RDMS, how these tasks are performed in general.

+4
source share
1 answer

There is a node package cronthat allows you to execute code at a specific interval, like crontab . Here's the link to the package: https://www.npmjs.org/package/cron

For instance:

var cronJob = require("cron").CronJob;

// Run this cron job every Sunday (0) at 7:00:00 AM
new cronJob("00 00 7 * * 0", function() {
    // insert code to run here...
}, null, true);

You may be able to use this module to periodically complete a specific task that scans twitter or responds to tweets.

+8
source

Source: https://habr.com/ru/post/1541767/


All Articles