Skip to content

IhaveDebt/Basic-Task-Scheduler-backend-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

package main

import ( "fmt" "time" )

func task(name string) { fmt.Println("⏰ Running task:", name, "at", time.Now()) }

func main() { schedule := map[string]time.Duration{ "Backup": 5 * time.Second, "Reminder": 10 * time.Second, }

for name, interval := range schedule {
	go func(name string, interval time.Duration) {
		for {
			time.Sleep(interval)
			task(name)
		}
	}(name, interval)
}

select {} // keep running

}

About

Runs tasks at specific times.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published