Defines an individual cron job.
Optional
timezone: Runs all given crons.
Optional
options: Readonly<import {defineCronSuite} from 'cron-vir';
type MyContext = {user: string};
const {defineCron, runCrons} = defineCronSuite<MyContext>();
const myCron = defineCron(
'my cron',
{
minute: '*',
hour: '*',
dayOfMonth: '*',
month: '*',
dayOfWeek: '*',
},
() => {
// do something
},
);
runCrons({user: 'ubuntu'}, [myCron]);
Define a cron suite with a context type. Use the output of this to define cron jobs and then, eventually, run them.