The jobs that run at night, where your team can see them.
Give an action a schedule and Pult runs it on time, in each environment, inside your app. Every run and its result lands in the audit log, and people can still run the same action by hand when they need to.
Cron, next to the code it runs
A cron expression, with a timezone if you want one. If your app can't be reached when a run is due, the run is recorded as failed instead of piling up for later.
export const weeklyDigest = action("weekly-digest", {
schedule: { cron: "0 9 * * 1", timezone: "Europe/Amsterdam" },
run: () => sendDigest(),
})
export const cleanup = action("nightly-cleanup", {
schedule: "0 3 * * *",
run: () => db.sessions.deleteExpired(),
})Audit log
Next: weekly digest, Monday at 9:00 AM
- Today, 3:00 AM
Schedule ran Nightly cleanup
Removed 1,204 expired sessions
- Monday, 9:00 AM
Schedule ran Weekly digest
Sent to 8,410 people
- Yesterday, 3:00 AM
Schedule ran Nightly cleanup
Removed 1,187 expired sessions
Long work, with progress
Actions that take a while run in the background and report how far they are. The console doesn't wait, and the history shows a progress bar and then the result.
export const reindex = action("reindex-search", {
label: "Rebuild search index",
background: true,
run: async ({ progress }) => {
const batches = await search.batches()
for (const [index, batch] of batches.entries()) {
await search.reindex(batch)
await progress((index + 1) / batches.length)
}
return "Search index rebuilt"
},
})What comes with it
- Checked before it ships
- pult check catches invalid cron expressions, input without defaults and approvals nobody could give.
- By hand, too
- Run a scheduled action from ⌘K or a button on any page, with the same permissions as everything else.
- Per environment
- Each environment runs its own schedule against its own app.
- On the record
- Every run is in the audit log under Schedule, with its result.
What it replaces
A crontab on one server nobody remembers, and digging through logs whenever someone asks whether last night's job ran.
Read how scheduled actions work