Giter Club home page Giter Club logo

node-cronlog's Introduction

node-cronlog

node-cronlog is lightweight node-js script that helps to log cron jobs (or other scripts) and send an email if something went wrong (using nodemailer + Gmail).

Email Setup

OPTIONAL: If you want to receive alerts via email if something went wrong

Create a file named ~/.cronlog/.env

GMAIL_USER="[email protected]"
GMAIL_PWD="**********"
MAIL_TO="[email protected]"

IMPORTANT NOTE: If you have enabled 2FA on your GMAIL account, you need to create an "App-specific password" from your gmail account settings.

USAGE

First, run npm install to install the dependencies.

Then, call the script.

# Launch the script
/path/to/cronlog.js <jobname> /path/to/command [options...] 

To use the script from CRON, install the package globally npm install -g /path/to/node-cronlog

* * * * * cronlog my_job_name echo "MY SCRIPT WORKS WELL"

The last result of each job will be stored in a SQLite file at ~/.cronlog/cronlog.sqlite

name cmd started completed duration output status
my_job_name echo MY SCRIPT WORKS WELL 2020-09-19T15:48:26.313Z 2020-09-19T15:48:26.319Z 0.006 MY SCRIPT WORKS WELL 0

node-cronlog's People

Stargazers

Nick Reese avatar

Watchers

Nicolas Anjoran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.