Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 23, 2022 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5ad7cdcd2e649667c0810d4ce1a863a1 to your computer and use it in GitHub Desktop.
Save parzibyte/5ad7cdcd2e649667c0810d4ce1a863a1 to your computer and use it in GitHub Desktop.
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