56 results available
Sign in
Skills directory

go-cron

encoredev

·

Last changed
Hardened

This skill has been hardened by Chainguard

Last changed

This version passed the hardening gate. Hardening applied 7 targeted changes and preserved all other text. Classified findings before hardening: 0. Classified findings closed: 0. Classified findings remaining: 0. Unclassified scanner findings remaining: 0. Review findings closed: 9. Review findings remaining: 2.


Open before hardening

None

Open after hardening

None


Expand
File
Group
Subtype
Severity
Status

No findings available

0 findings


SKILL.md

Encore Go Cron Jobs

Instructions

A cron.NewJob declaration in Encore Go ties a schedule to an existing //encore:api endpoint. The endpoint runs at the chosen cadence. Declare the job as a package-level variable — not inside a function.

package cleanup

import (
    "context"
    "encore.dev/cron"
)

// 1. The endpoint to call (private by default: //encore:api private)
//encore:api private
func CleanupExpiredSessions(ctx context.Context) error {
    // Cleanup logic
    return nil
}

// 2. Package-level cron declaration
var _ = cron.NewJob("cleanup-sessions", cron.JobConfig{
    Title:    "Clean up expired sessions",
    Schedule: "0 * * * *", // Every hour
    Endpoint: CleanupExpiredSessions,
})

Schedule Formats

FieldExampleDescription

Every

"1h", "30m", "6h"

Simple interval. Must divide 24h evenly — "7h" is invalid.

Schedule

"0 9 * * 1"

Standard cron expression (5 fields, UTC).

Set exactly one of Every or Schedule in the job config, never both.

Common cron expressions

CronMeaning

"0 * * * *"

Every hour, on the hour

"0 2 * * *"

Daily at 02:00 UTC

"0 0 * * 0"

Weekly on Sunday at midnight UTC

"0 4 15 * *"

04:00 UTC on the 15th of each month

Important behaviour

  • Cron jobs do not execute when running locally with encore run. Only deployed environments fire crons. To check the job logic before deploying, call the endpoint function directly while developing, and verify it in a test environment before production.
  • Declare the cron endpoint private by default so it can't be triggered externally. Other services in the same app can still call it, so keep validation and safety limits inside the handler.
  • All times in Schedule are UTC. Convert from local time when designing the schedule.
  • Cron endpoints take no request payload: they accept only a context and return an error, like the example above.
  • The endpoint must be an //encore:api function referenced from a package-level cron.NewJob declaration; declaration order within the package does not matter.

Guidelines

  • Use Every for "run on a regular interval" (must divide 24h).
  • Use Schedule for specific times of day or days of week.
  • Keep endpoint logic idempotent: invocations may fire late, overlap or repeat, for example around redeploys.
  • For event-driven background work (not time-driven), use the encore-go-pubsub skill instead.

Install

Install with chainctl
chainctl skill install public/encoredev/go-cron:latest
Get started with chainctl
View source

Harden your own skills

Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.

Provenance

Upstream sourcehttps://github.com/encoredev/skills
Upstream commitcb69bb1f246274419aed69c84ee5815955c4c499
OCI reference

skills.cgr.dev/public/github.com/encoredev/encore/go-cron:latest

License

Apache-2.0

Files

HARDENING.md

LICENSE

SKILL.md


The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.