goo_cron

package
v1.1.198 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

定时任务

  • 阻塞模式
c := goo_cron.Default()

c.Second(func() {
    fmt.Println("--1---", time.Now().Format("15:04:05"))
    time.Sleep(3 * time.Second)
    fmt.Println("--2---", time.Now().Format("15:04:05"))
})

c.Run()
  • 非阻塞模式
c := goo_cron.Default()

c.Second(func() {
    fmt.Println("--1---", time.Now().Format("15:04:05"))
    time.Sleep(3 * time.Second)
    fmt.Println("--2---", time.Now().Format("15:04:05"))
})

c.Start()
defer func() {
    <- c.Stop().Done()
}

shell 检查任务是否退出

说明:

  • kill -1 终端断线,重新加载
  • kill -2 中断,同ctrl+c
  • kill -3 退出
  • kill -9 强制终止
cd /opt
kill -3 `pidof /opt/s.s`
for n in {1..60}; do
    sleep 1s
    pid=`pidof /opt/s.s`
    if [ "\$pid" == "" ]; then
        nohup /opt/s.s >> logs/log.log 2>&1 &
        break
    fi
done

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default added in v1.1.157

func Default() *crontab

func New added in v1.1.157

func New(opts ...cron.Option) *crontab

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL