# expressweb-scheduler-ts

> This library provides an easy way to schedule recurring tasks in ExpressWebjs and also node/express.

Latest version **1.0.6** (published 2024-04-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install expressweb-scheduler-ts
pnpm add expressweb-scheduler-ts
yarn add expressweb-scheduler-ts
bun add expressweb-scheduler-ts
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2024-04-01 |
| First published | 2021-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AlexIgbokwe |
| Maintainers | alexigbokwe |
| Keywords | ExpressWebjs, Typescript, task, scheduler, cron, node-cron, nodejs, expressjs |

## Links

- npm: https://www.npmjs.com/package/expressweb-scheduler-ts
- npm.io page: https://npm.io/package/expressweb-scheduler-ts

## Dependencies (2)

- [shelljs](https://npm.io/package/shelljs.md) ^0.8.4
- [node-cron](https://npm.io/package/node-cron.md) ^2.0.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2024-04-01
- 1.0.5 — 2024-04-01
- 1.0.4 — 2022-01-14
- 1.0.3 — 2022-01-14
- 1.0.2 — 2021-04-24
- 1.0.1 — 2021-04-24
- 1.0.0 — 2021-04-24

## README

<div align="center">
  <img src="https://expresswebjs.com/logo.png" width="600px">
</div>
<br />
<hr>

# ExpressWebJs Scheduler Typescript Version

The software utility cron also known as cron job is a time-based job scheduler in computer operating systems. Users that set up and maintain software environments use cron to schedule jobs to run periodically at fixed times, dates, or intervals. ExpressWebJs Scheduler makes that really easy to achieve.

## Getting started

- First install expressweb-scheduler-ts

```
    npm install --save expressweb-scheduler-ts
```

- Import Scheduler

```ts
import { Schedule } from "expressweb-scheduler-ts";
```

- Schedule a command

```ts
Schedule.command("sendNewsletter").everySecond().run();
```

- You can also run a closure function using the call method

```ts
Schedule.call(() => {
  console.log("this is a closure that is been run every seconds");
})
  .everySecond()
  .run();
```

- You can also use the cron method:

```ts
Schedule.command("sendNewsletter").cron("* * * * * *").run();
```

    Allowed fields in cron method

    # ┌────────────── second (optional)
    # │ ┌──────────── minute
    # │ │ ┌────────── hour
    # │ │ │ ┌──────── day of month
    # │ │ │ │ ┌────── month
    # │ │ │ │ │ ┌──── day of week
    # │ │ │ │ │ │
    # │ │ │ │ │ │
    # * * * * * *

## Allowed Values And Schedule Frequency Options

We've already seen a few examples of how you may configure a task to run at specified intervals. However, there are many more task schedule frequencies that you may assign to a task:

<table>
<thead>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-&gt;second</code></td>
<td>0-59</td>
</tr>
<tr>
<td><code>-&gt;minute</code></td>
<td>0-59</td>
</tr>
<tr>
<td><code>-&gt;hour</code></td>
<td>0-23</td>
</tr>
<tr>
<td><code>-&gt;day of month</code></td>
<td>1-12 (or names) </td>
</tr>
<tr>
<td><code>-&gt;month</code></td>
<td>1-12 (or names) </td>
</tr>
<tr>
<td><code>-&gt;day of week</code></td>
<td>0-7 (or names, 0 or 7 are sunday)</td>
</tr>
</tbody>
</table>
<hr>

<table>
<thead>
<tr>
<th>Method</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-&gt;cron('* * * * *');</code></td>
<td>Run the task on a custom cron schedule</td>
</tr>
<tr>
<td><code>-&gt;everyMinute();</code></td>
<td>Run the task every minute</td>
</tr>
<tr>
<td><code>-&gt;everyTwoMinutes();</code></td>
<td>Run the task every two minutes</td>
</tr>
<tr>
<td><code>-&gt;everyThreeMinutes();</code></td>
<td>Run the task every three minutes</td>
</tr>
<tr>
<td><code>-&gt;everyFourMinutes();</code></td>
<td>Run the task every four minutes</td>
</tr>
<tr>
<td><code>-&gt;everyFiveMinutes();</code></td>
<td>Run the task every five minutes</td>
</tr>
<tr>
<td><code>-&gt;everyTenMinutes();</code></td>
<td>Run the task every ten minutes</td>
</tr>
<tr>
<td><code>-&gt;everyFifteenMinutes();</code></td>
<td>Run the task every fifteen minutes</td>
</tr>
<tr>
<td><code>-&gt;everyThirtyMinutes();</code></td>
<td>Run the task every thirty minutes</td>
</tr>
<tr>
<td><code>-&gt;hourly();</code></td>
<td>Run the task every hour</td>
</tr>
<tr>
<td><code>-&gt;hourlyAt(17);</code></td>
<td>Run the task every hour at 17 minutes past the hour</td>
</tr>
<tr>
<td><code>-&gt;everyTwoHours();</code></td>
<td>Run the task every two hours</td>
</tr>
<tr>
<td><code>-&gt;everyThreeHours();</code></td>
<td>Run the task every three hours</td>
</tr>
<tr>
<td><code>-&gt;everyFourHours();</code></td>
<td>Run the task every four hours</td>
</tr>
<tr>
<td><code>-&gt;everySixHours();</code></td>
<td>Run the task every six hours</td>
</tr>
<tr>
<td><code>-&gt;daily();</code></td>
<td>Run the task every day at midnight</td>
</tr>
<tr>
<td><code>-&gt;dailyAt('13:00');</code></td>
<td>Run the task every day at 13:00</td>
</tr>
<tr>
<td><code>-&gt;twiceDaily(1, 13);</code></td>
<td>Run the task daily at 1:00 &amp; 13:00</td>
</tr>
<tr>
<td><code>-&gt;weekly();</code></td>
<td>Run the task every Sunday at 00:00</td>
</tr>
<tr>
<td><code>-&gt;weeklyOn(1, '8:00');</code></td>
<td>Run the task every week on Monday at 8:00</td>
</tr>
<tr>
<td><code>-&gt;monthly();</code></td>
<td>Run the task on the first day of every month at 00:00</td>
</tr>
<tr>
<td><code>-&gt;monthlyOn(4, '15:00');</code></td>
<td>Run the task every month on the 4th at 15:00</td>
</tr>
<tr>
<td><code>-&gt;twiceMonthly(1, 16, '13:00');</code></td>
<td>Run the task monthly on the 1st and 16th at 13:00</td>
</tr>
<tr>
<td><code>-&gt;lastDayOfMonth('15:00');</code></td>
<td>Run the task on the last day of the month at 15:00</td>
</tr>
<tr>
<td><code>-&gt;quarterly();</code></td>
<td>Run the task on the first day of every quarter at 00:00</td>
</tr>
<tr>
<td><code>-&gt;yearly();</code></td>
<td>Run the task on the first day of every year at 00:00</td>
</tr>
<tr>
<td><code>-&gt;yearlyOn(6, 1, '17:00');</code></td>
<td>Run the task every year on June 1st at 17:00</td>
</tr>
<tr>
<td><code>-&gt;timezone('America/New_York');</code></td>
<td>Set the timezone for the task</td>
</tr>
</tbody>
</table>

Visit [ExpressWebJs Documentation site](https://expresswebjs.com/) for more info.

<a href="https://expresswebjs.com/">ExpressWebJs</a> is a powerful and flexible Node FrameWork for building efficient and scalable backend services for modern applications. It is designed to be easy to use and flexible, allowing you to build a wide range of backend services.

It includes support for enterprise-level features such as building multi-tenant systems, distributed systems, multi-threading, real-time events, queues, dependency injection, testing, and more. With ExpressWebJs, you can easily build efficient and reliable backend services that can handle a large volume of traffic and data.

---
_Source: https://npm.io/package/expressweb-scheduler-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
