Runtime check inside the job
The cleanest pattern: schedule daily, check if today is the last day, exit early otherwise. The schedule expression stays standard cron; the “last day” logic lives in Go where it's easier to test.
package main
import (
"time"
"github.com/robfig/cron/v3"
)
func isLastDayOfMonth(t time.Time) bool {
return t.AddDate(0, 0, 1).Day() == 1
}
func main() {
c := cron.New()
c.AddFunc("0 0 * * *", func() {
if !isLastDayOfMonth(time.Now()) {
return
}
// ... your last-day-of-month work here
})
c.Start()
select {}
}