Issue
When developing the telegram bot in python, I faced the problem of independently triggering notifications in the Ubuntu system. Let's start from the beginning. For everyday notification, I use a library called "Schedule". I won't fully describe it in the code, but it looks something like this:
from multiprocessing import *
import schedule
def start_process():
Process(target=P_schedule.start_schedule, args=()).start()
class P_schedule():
def start_schedule():
schedule.every().day.at("19:00").do(P_schedule.send_message)
while True:
schedule.run_pending()
time.sleep(1)
def send_message():
bot.send_message(user_ID, 'Message Text')
There don't seem to be any errors here for correct operation. Then I loaded all this into the Ubuntu system and connected "systemd" to autorun with commands:
vim /etc/systemd/system/bot.service
[Unit]
Description=Awesome Bot
After=syslog.target
After=network.target
[Service]
Type=simple
User=bot
WorkingDirectory=/home/bot/tgbot
ExecStart=/usr/bin/python3 /home/bot/tgbot/bot.py
Restart=always
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable bot
systemctl start bot
I restart "systemd" after making edits to the code with a command:
systemctl restart bot
The problem arose in the following, when I change the time of the notification, it starts coming at the time that I specified and at the time that was before, as I understand it, "systemd" somewhere in the cache stores the old time value. How can I update "systemd" to clear this very cache.
Solution
It helped to reboot the system with the command:
sudo systemctl reboot
Answered By - Friken Answer Checked By - Mary Flores (WPSolving Volunteer)