Skip to content

kozakvoj/is-time-to-run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

is-time-to-run

NPM

Motivation

I run a script which checks availability of websites. This script is run in crone every 5 minutes. If any of the website is unavailable I need to send an e-mail. But I don't want to send this e-mail every 5 minutes but every hour.

This module allows to check if certain period of time has passed and allow your script to run again. It aims at stateless scripts (that don't run in loop as a daemon) and for this purpose it utilises a helper file where it stores information about the last time your script has run.

API

isTime(callback)

This method will return information if your code can be executed again. If it can it will change the helper file to the current time.

Usage

var IsTimeToRun = require('is-time-to-run');

var timeChecker = new IsTimeToRun({
    path: 'tmp/',   # default ''
    period: '30',   # default 60
    unit: 'minutes' # default 'minutes'
});

timeChecker.isTime((err, canRun) => {
    
});

About

Allows repeating your script after certain period of time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published