K
K
kicherov_maxim2020-03-25 21:45:36
Task Schedulers
kicherov_maxim, 2020-03-25 21:45:36

How to run scripts according to the time specified in the database?

Good evening. How best to organize the next task. The database stores full name, phone numbers, and a convenient time for mailing. It is necessary to carry out mailing every day at an individually convenient time.

The idea is, let's say at midnight to form messages with the status not sent in a separate table, and then in the crown every minute to do a SELECT from this table and check if status = not sent and time < current, then send and change the status. It confuses me, if the entire sending takes longer than a minute, it will probably be bad ...

I look towards celery, rabbitmq I can’t understand for this they or not for this, maybe somehow there can be a queue formed for sending?

Can you tell me what architectural solutions can be applied?

PS UBUNTU OS, python language, postgres database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-03-25
@firedragon

E script that runs every 1 minute or every 5 minutes and pulls out the time of sending.
For perfectionism, you can set up a local mailer with sending limits, so as not to spam the mail server, and also handle the rejection of letters.

G
Germanjon, 2020-03-26
@Germanjon

How important is it to send messages at a specific time (for example, at 08:33:57)? Can messages be sent with plus or minus hour accuracy?
If possible, it is enough to create 24 files of the form send_at_0900.txt, each of which contains the mailing addresses of the upcoming shipment. And then, once an hour, run the script over the required file and ensure the sending (as already mentioned above, " you can configure a local mailer with sending limits so as not to spam the mail server, and process the rejection of letters. ").

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question