Compare commits
No commits in common. "d6a36c62d6125c2248220a17ef72485f42222ed8" and "e4e05b58f7d13b9f045a3a8732a7c75ec5ac7f19" have entirely different histories.
d6a36c62d6
...
e4e05b58f7
15
cmd/main.go
15
cmd/main.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
@ -14,9 +13,10 @@ import (
|
|||
|
||||
var maxRetries = 0
|
||||
var now = time.Now()
|
||||
var liveMode bool
|
||||
|
||||
func main() {
|
||||
fmt.Println("-----------------------------------------------------------------------------------------")
|
||||
fmt.Println("-----------------------------------------------------------------------------------------")
|
||||
log.Println(`
|
||||
_____
|
||||
_/ ____\______ ____ _____ _____ ____ __ _ _______ ____ ____
|
||||
|
@ -26,10 +26,6 @@ _/ ____\______ ____ _____ _____ ____ __ _ _______ ____ ____
|
|||
\/ \/ \/ \//_____/ `)
|
||||
fmt.Println("-----------------------------------------------------------------------------------------")
|
||||
fmt.Println("-----------------------------------------------------------------------------------------")
|
||||
flag.BoolVar(&liveMode, "liveMode", false, "即时模式关闭")
|
||||
flag.Parse()
|
||||
if !liveMode {
|
||||
fmt.Println("目前时定时任务模式")
|
||||
if maxRetries < 3 {
|
||||
for {
|
||||
remainingTime := tools.RemainingTimeUntilNextFriday17()
|
||||
|
@ -37,7 +33,7 @@ _/ ____\______ ____ _____ _____ ____ __ _ _______ ____ ____
|
|||
break // 当剩余时间小于等于0时跳出循环
|
||||
}
|
||||
fmt.Printf("距离执行定时任务还剩 %d小时 %d分钟 %d秒\n", int(remainingTime.Hours()), int(remainingTime.Minutes())%60, int(remainingTime.Seconds())%60)
|
||||
time.Sleep(time.Minute * 10) // 等待10分钟,然后更新
|
||||
time.Sleep(time.Minute * 10) // 等待30分钟钟,然后更新
|
||||
}
|
||||
// 定义任务,每周五的五点执行
|
||||
gocron.Every(1).Friday().At("17:00").Do(job)
|
||||
|
@ -47,11 +43,6 @@ _/ ____\______ ____ _____ _____ ____ __ _ _______ ____ ____
|
|||
} else {
|
||||
log.Fatalln("最大重试次数已到达3,退出")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("目前时即时任务模式")
|
||||
job()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func job() {
|
||||
|
|
Loading…
Reference in New Issue