Send & receive text messages everyday (Python)

Here is my code :

from zeep import Client
from datetime import datetime
from threading import Timer
def send_simple_sms(txt):
    send_url = 'URL'
    client = Client(send_url)
    username = "MyUsername"
    password = "Password"
    text = txt
    to_type = client.get_type('ns0:ArrayOfString')
    to = to_type(['xxxxxxxxxxx'])
    from_ = "xxxxxxxx"
    result = client.service.SendSimpleSMS(username, password, to, from_, text, False)
    print(result)
def timer8():
    send_simple_sms('fff')
def timer9():
    send_simple_sms('sss')
def timer10():
    send_simple_sms('aaa')
def timer14():
    send_simple_sms('uuu')
def timer00():
    send_simple_sms('ppp')
td = datetime.today()
_8clock = td.replace(day=td.day+1, hour=8, minute=0, second=0, microsecond=0)
_9clock = td.replace(day=td.day+1, hour=9, minute=0, second=0, microsecond=0)
_10clock = td.replace(day=td.day+1, hour=10, minute=0, second=0, microsecond=0)
_14clock = td.replace(day=td.day+1, hour=14, minute=0, second=0, microsecond=0)
_00clock = td.replace(day=td.day+1, hour=0, minute=0, second=0, microsecond=0)
delta_8 = _8clock - td
delta_9 = _9clock - td
delta_10 = _10clock - td
delta_14 = _14clock - td
delta_00 = _00clock - td
secs8 = delta_8.seconds+1
secs9 = delta_9.seconds+1
secs10 = delta_10.seconds+1
secs14 = delta_14.seconds+1
secs00 = delta_00.seconds+1
Timer(secs8, timer8)
Timer(secs9, timer9)
Timer(secs10, timer10)
Timer(secs14, timer14)
Timer(secs00, timer00)

I want to receive somethings (like text messages) everyday at these times : 8:0:0 9:0:0 10:0:0 14:0:0 0:0:0 I’ve done this till here. But i have problem to use all times together. Can you help me? What should i do?

Answer

If your code is running on a linux environment the best way is to use crontab, so that your code isn’t always running. You configure your script to run once and then you launch it with crontab at days and hours you want. Here you can find the simplest info about crontab.