R
R
RandomProgrammer2021-10-08 00:01:50
Python
RandomProgrammer, 2021-10-08 00:01:50

Is it possible to control the timing?

Is it possible to somehow assign an event to occur, for example, 12:30, or will you have to check every second if the right time has not come?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
Zettabyte, 2021-10-08
@Zettabyte

Is it possible to somehow assign an event to occur for example 12:30

crontabwith the full path to your script:
30 12 * * * /usr/bin/python /home/RandomProgrammer/scripts/event.py

The correct path must be specified at the beginning of event.py: #!/usr/bin/python
Also, the script must be given execute permission:chmod a+x event.py

V
Vindicar, 2021-10-08
@Vindicar

The correct solution would be to use the OS scheduler (cron on Linux, task scheduling on Windows).
But if you really need a solution in pure Python, the schedule package will help. Only it requires an eternal loop to work, so your script will hang in memory and eat a little bit of percent. That's why I advise you to get by with OS tools.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question