Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 23, 2022 17:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
func main() {
err := crearTablas()
if err != nil {
log.Printf("Error creando tablas: %v", err)
return
}
c := cron.New()
defer c.Stop()
// Agregarle funciones...
// Ejecutar cada segundo toda la vida
err = c.AddFunc("0 */1 * * *", func() {
log.Printf("Soy cron")
revisarGistYCambiarImagenSiEsNecesario()
})
if err != nil {
log.Printf("Error iniciando cron: %v", err)
return
}
// Comenzar
c.Start()
// Lo siguiente es únicamente para pausar el programa y no tiene nada
// que ver con cron o el ejemplo, recuerda que
// el programa se detiene con Ctrl + C
select {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment