package cmd import ( "context" "fmt" "kpt-pasture/config" "kpt-pasture/store/kptstore" "gitee.com/xuyiping_admin/pkg/cmd" "github.com/spf13/cobra" ) // CrontabCmd represents the crontab command var CrontabCmd = &cobra.Command{ Use: "crontab", Short: "计划任务", Run: func(cmd *cobra.Command, args []string) { fmt.Println("crontab called") }, } func init() { // 每日同步脚本 cmd.Instant(JobCmd, "update:cowAge", UpdateCowDayAge, "更新牛只日龄") } func UpdateCowDayAge(ctx context.Context, args []string) error { cfg := config.Options() db := kptstore.MustMigrateStore(cfg) sqlDB, err := db.DB() if err != nil { panic(err) } defer sqlDB.Close() return nil }