Task schedule is a piece of shit

Published: (April 30, 2026 at 04:06 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Overview

Run your TypeScript file at a specific time. The library supports three scheduling methods:

  • interval – run repeatedly at a set interval
  • atTime – run once at a specific time each day
  • inRange – run within a defined time range

For detailed options, see api.ts.

Creating a Script

  1. Create a TypeScript file in the scripts folder with the .sche.ts extension.
  2. Import the API and instantiate it.
// import API from api.ts
import { API } from './api.ts';

// instantiate API
const timer = new API();

Examples

Interval

Run a function every 5 minutes:

timer.interval({
    min: 5,
    func: () => {
        console.log('hello world');
    }
});

At a Specific Time

Run a function every day at 10:00:

timer.atTime({
    time: '10:00',
    func: () => {
        console.log('hello world');
    }
});

Startup with the OS

To launch the script automatically on system start, create a shortcut (Alt + Drag) and place it in the shell:startup folder.

Using Packages

If your script requires additional packages, initialize an npm project and install dependencies using npm or bun.

npm init -y
npm install 
# or with bun
bun init
bun add 

Configuration

You can adjust the checkInterval setting in api.ts to change how frequently the scheduler checks for pending tasks.

0 views
Back to Blog

Related posts

Read more »

Formatting a 25M-line codebase overnight

!Fig. 1https://stripe.dev/art/index.html?config=%7B%22ampX%22:0.4619596366584301,%22ampY%22:0.9206785130240023,%22aspectRatio%22:1.3698673702020199,%22axis%22:%...