Forums

Scheduled tasks in Web App

Hi Guys!

I am new to the PythonAnywhere and to the hosting code on servers in general. I've got a question about running scheduled tasks in my web app. For example, I want to send email to myself with logs every day at 12.00 am. I can do it if I introduce special function and after that call it with the command (I am buildin a telegram bot), but I don't want call it every time.

While testing on my local laptop in Pycharm I used

schedule.every().day.at("06:00").do(SendEMail, ('Daily Status Check: ' + datetime.now(moscowTimeZone).strftime('%d.%m.%Y %H:%M'), 'I am OK!'))

with

import schedule

and no webhooks.

But I guess, this doesn't work in web app. So how should I execute this task? Is it even possible for web app to schedule tasks which will access web app's code data?

Why not just run it as a scheduled task? You can still load code from your web app, and access any permanent storage (filesystem, database...)