npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

scriptcron

v1.0.7

Published

Node.js-based cron scheduler

Downloads

19

Readme

scriptcron

What is scriptcron?

scriptcron is a simple, no-fuss tool to schedule and run scripts based on a configuration file. Whether you need to run shell scripts or JavaScript files on a regular schedule, scriptcron has you covered. Plus, it comes with built-in logging and graceful shutdown support, so everything runs smoothly.


Why use scriptcron?

  • Easy scheduling: Use familiar cron expressions to set up jobs.
  • Run any script: Supports shell scripts, JavaScript files, and customizable arguments.
  • Customizable logging: Log to the console, files, or turn it off entirely.
  • Graceful stops: Cleanly shuts down all jobs when the process ends.

Getting Started

Step 1: Install the package

First, install scriptcron using npm:

npm install scriptcron

Step 2: Set up your configuration

Create a file to define your jobs and logging preferences. Here's an example:

Example config.js:

module.exports = {
  scripts: [
    {
      path: "test.sh", // A shell script
      enabled: true,   // Turn this job on or off
      args: ["arg1", "arg2"], // Arguments for the script
      frequency: "*/5 * * * * *" // Every 5 seconds
    },
    {
      path: "test.js", // A JavaScript file
      enabled: true,
      args: ["arg1", "arg2"],
      frequency: "*/5 * * * *" // Every 5 minutes
    },
    {
      path: "/vol/scripts/example.js", // Absolute path example
      enabled: true,
      args: ["arg1", "arg2"],
      frequency: "*/10 * * * *" // Every 10 minutes
    }
  ],
  logSettings: { // Optional
    logTo: "file", // Options: "none", "console", "file"
    baseDir: "/vol1/logs/scriptcron" // Where to store log files
  },
  defaultScriptDir: __dirname // Where to look for relative script paths
};

Step 3: Run the scheduler

Create a simple script to start the agent and load your configuration:

Example main.js:

const { makeScriptCronAgent } = require('scriptcron');
const path = require('path');

const agent = makeScriptCronAgent({ configPath: path.join(__dirname, './config.js') });

// Graceful shutdown when you stop the process
process.on('SIGINT', () => {
    console.log("Shutting down...");
    agent.stop();
    process.exit(0);
});

Run it with Node.js:

node main.js

And that's it! Your scripts will now run on the schedule you defined.


Contributing

We’d love your help to make scriptcron even better! Found a bug? Have an idea? Open an issue or send us a pull request on GitHub.


License

scriptcron is licensed under the ISC License. Do whatever you like with it—just give credit where it’s due.