mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 16:26:25 +00:00
cron job
This commit is contained in:
parent
03ca0c8677
commit
d293e93fa8
@ -3,8 +3,7 @@ package internal
|
|||||||
func RunCron() error {
|
func RunCron() error {
|
||||||
c := GetConfig()
|
c := GetConfig()
|
||||||
for _, l := range c.Locations {
|
for _, l := range c.Locations {
|
||||||
err := l.RunCron()
|
if err := l.RunCron(); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,16 +207,14 @@ func (l Location) RunCron() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
last := lock.GetCron("test")
|
last := time.Unix(lock.GetCron(l.Name), 0)
|
||||||
fmt.Println(last)
|
next := schedule.Next(last)
|
||||||
next := schedule.Next(time.Unix(last, 0))
|
|
||||||
fmt.Println(next)
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if now.After(next) {
|
if now.After(next) {
|
||||||
fmt.Println("Running")
|
lock.SetCron(l.Name, now.Unix())
|
||||||
lock.SetCron("test", now.Unix())
|
l.Backup()
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Not due yet")
|
fmt.Printf("Skipping \"%s\", not due yet.\n", l.Name)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user