0

I was wondering if it was possible to have a web service running on Flask to execute a function at a certain time every day.

I'm making a Slack bot with Flask and Python, and I want the bot to send out a reminder every day at 6:00 to a channel.

Is it possible to keep track of the current time continuously, and only perform an action once the current time equals a set time?

mx0
  • 6,445
  • 12
  • 49
  • 54
Davis Keene
  • 213
  • 1
  • 5
  • 12

1 Answers1

1

You could, but that is not a good way of doing it. Your operating system almost certainly has this functionality built-in; on unix-like systems for example you would use cron.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • 1
    I tried using an APScheduler cron job, but the problem with that was that it had to be run as a separate job, or else the cron jobs would be blocking the Flask tasks from running. I'd rather keep everything in one project. – Davis Keene Feb 18 '18 at 19:05