A decentralized music tracking and discovery platform built on AT Protocol 馃幍
listenbrainz
spotify
atproto
lastfm
musicbrainz
scrobbling
1#!/usr/bin/env -S deno run --unstable-cron -A
2
3/// <reference lib="deno.ns" />
4/// <reference lib="dom" />
5
6import chalk from "chalk";
7
8const args = Deno.args;
9
10if (args.length < 2) {
11 console.log(
12 chalk.greenBright("Usage: cron <interval-in-minutes> <command> [args...]")
13 );
14 Deno.exit(0);
15}
16
17const interval = parseInt(args[0], 10);
18if (Number.isNaN(interval) || interval <= 0) {
19 console.error("Interval must be a positive integer");
20 Deno.exit(1);
21}
22
23Deno.cron("cron", { minute: { every: interval } }, async () => {
24 const command = new Deno.Command(args[1], {
25 args: args.slice(2),
26 stdout: "inherit",
27 stderr: "inherit",
28 });
29 const child = command.spawn();
30 const status = await child.status;
31 if (!status.success) {
32 console.error(`Cron job failed with code ${status.code}`);
33 }
34 console.log(`Cron job executed at ${new Date().toISOString()}`);
35});