Forums

Is it possible to track the shutdown of the bot

I can somehow track that my telegram bot has turned off (it does not respond to commands) without going to the hosting site (it seems this is due to an overload of the hosting servers). After disabling the bot in the console, only this ">>> ". I use to run the polling bot

You could log / print that the bot is shutting down

the problem is that logging (the log just doesn't show up in the file) doesn't work. Most likely, this is due to the fact that the bot does not turn off, but simply the hosting servers are overloaded

What file are you expecting the logging to go to? Is this just a misconfiguration with the logging settings?

Upon completion, my bot (aiogram) writes data to a log file and must write to me in telegram. On my PC, when I turn it off, it works, but on the hosting it not works because it's like a computer when you turn it off through a button or unplug it from the socket

Ah, I see the problem. It looks like you're running your bot from a console inside PythonAnywhere. Consoles are designed for interactive sessions, not for long-running programs, and so the console servers are sometimes reset, which would make your bot exit.

If you want to run a script and keep it running forever, you would need a paid account -- then you could use an always-on task.

I do not have the opportunity to buy this, as I understand it, there is no way to find out that the bot has turned off in my situation?

There's nothing built into PythonAnywhere for that, unfortunately. You could perhaps set it up so that it sends you a message periodically, and monitor to see if it stops doing that?

Okay, thanks a lot.

Hope that helped