Golang - How to execute a function at a specific time

I need to run a function at a specific time of the day (e.g. 0010, 0610, 1210, 1810). My current approach uses a ticker for _ = range time.Tick(21600 * time.Second), and I manually run the program at one of these intervals (e.g. 1210). This is obviously not optimal.

What is the best solution for this? I thought about starting a ticker every 60 seconds, and then checking to see if the time corresponds to one of the intervals, but it does not look very elegant.

+4
source share
1 answer

Being here really is a planner, so your options are:

  • , , . cron ( Windows, Task Scheduler),

  • , . ( Windows) -

+3

Source: https://habr.com/ru/post/1615930/


All Articles