# @backstage/backend-tasks

> Common distributed task management library for Backstage backends

Latest version **0.6.1** (published 2024-08-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @backstage/backend-tasks
pnpm add @backstage/backend-tasks
yarn add @backstage/backend-tasks
bun add @backstage/backend-tasks
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score; popular repo.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.6.1 |
| Published | 2024-08-27 |
| First published | 2021-11-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 157.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 34418 |
| Maintainers | patriko, freben, marcuseide |
| Keywords | backstage |

## Links

- npm: https://www.npmjs.com/package/@backstage/backend-tasks
- Repository: https://github.com/backstage/backstage
- Homepage: https://backstage.io
- npm.io page: https://npm.io/package/@backstage/backend-tasks

## Dependencies (13)

- [zod](https://npm.io/package/zod.md) ^3.22.4
- [cron](https://npm.io/package/cron.md) ^3.0.0
- [knex](https://npm.io/package/knex.md) ^3.0.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [luxon](https://npm.io/package/luxon.md) ^3.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@types/luxon](https://npm.io/package/@types/luxon.md) ^3.0.0
- [@backstage/types](https://npm.io/package/@backstage/types.md) ^1.1.1
- [@backstage/config](https://npm.io/package/@backstage/config.md) ^1.2.0
- [@backstage/errors](https://npm.io/package/@backstage/errors.md) ^1.2.4
- [@opentelemetry/api](https://npm.io/package/@opentelemetry/api.md) ^1.3.0
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.24.1
- [@backstage/backend-plugin-api](https://npm.io/package/@backstage/backend-plugin-api.md) ^0.8.1

## Recent versions

- 0.6.1 (latest) — 2024-08-27
- 0.0.0-nightly-20240828022712 (nightly) — 2024-08-28
- 0.6.2-next.0 (next) — 2024-08-27
- 0.0.0-nightly-20240827082736 — 2024-08-27
- 0.0.0-nightly-20240827022616 — 2024-08-27
- 0.0.0-nightly-20240826083204 — 2024-08-26
- 0.0.0-nightly-20240826071828 — 2024-08-26
- 0.0.0-nightly-20240826022541 — 2024-08-26
- 0.0.0-nightly-20240825022831 — 2024-08-25
- 0.0.0-nightly-20240825022300 — 2024-08-25
- 0.0.0-nightly-20240824022004 — 2024-08-24
- 0.0.0-nightly-20240823021944 — 2024-08-23
- 0.0.0-nightly-20240822021958 — 2024-08-22
- 0.6.0 — 2024-08-20
- 0.0.0-nightly-20240820021901 — 2024-08-20
- … 969 more at https://npm.io/package/@backstage/backend-tasks/versions

## README

# @backstage/backend-tasks

> [!CAUTION]
> This package is deprecated and will be removed in a near future.

Common distributed task management for Backstage backends.

## Usage

> [!CAUTION]
> Please note that the documentation below is only valid for versions equal to or below `0.5.28-next.3`.
> As this package will be deleted soon, we recommend that you migrate to the new backend system, and depend on `coreServices.scheduler` from `@backstage/backend-plugin-api` instead, or use `DefaultSchedulerService` from `@backstage/backend-defaults`. Here are the [backend](https://backstage.io/docs/backend-system/building-backends/migrating) and [plugin](https://backstage.io/docs/backend-system/building-plugins-and-modules/migrating) migration guides.

Add the library to your backend package:

```bash
# From your Backstage root directory
yarn --cwd packages/backend add @backstage/backend-tasks
```

then make use of its facilities as necessary:

```typescript
import { TaskScheduler } from '@backstage/backend-tasks';

const scheduler = TaskScheduler.fromConfig(rootConfig).forPlugin('my-plugin');

await scheduler.scheduleTask({
  id: 'refresh_things',
  frequency: { cron: '*/5 * * * *' }, // every 5 minutes, also supports Duration
  timeout: { minutes: 15 },
  fn: async () => {
    await entityProvider.run();
  },
});
```

---
_Source: https://npm.io/package/@backstage/backend-tasks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
