M
M
Michael2017-03-10 09:38:26
Django
Michael, 2017-03-10 09:38:26

Execute python script every 24 hours?

The task is next. The site is developed with django. There is a table with which you need to perform some operations every 24 hours.
With what help to implement?
I visited time.sleep, but I think it doesn't fit. I looked in the direction of cron, but did not understand how to start it.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Q
qlkvg, 2017-03-10
@qlkvg

https://docs.python.org/3/library/sched.html from the standard library, or a more convenient 3rd party https://pypi.python.org/pypi/schedule

S
Saboteur, 2017-03-10
@saboteur_kiev

Cron is very easy to set up. As the user on whose behalf you want to run the script, set up the crontab file
crontab -e
and add the line
0 0 * * *
which means - at zero second, zero hour (0:00), every day of the month, every month, every day of the week, execute command
Write a call to your script as a command.
Take care to specify the full path to the files.

D
dzh21, 2017-03-16
@dzh21

there is another option to use Schedule tasks from Celery

F
Finger Gross, 2017-03-19
@GrossFinger

https://djangopackages.org/grids/g/cron/ - many options

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question