简体   繁体   中英

How can I get a python code to run over and over again?

I have a scraper that scrapes data from a website, then saves the data in .csv files. What I am looking for is a way to run this code every 10 minutes, without using a loop. I have very little knowledge on how to do this. What approach would you use?

It's impossible to repeat a code without a loop.

I can only think that you want something like Task Scheluding on Windows ( https://msdn.microsoft.com/pt-br/library/windows/desktop/aa383614.aspx ) or crontab/timers on Linux.

Are you using windows or a unix based system?

If you're using UNIX, you can schedule jobs to take place at regular intervals with CRON.

Execute the following in a terminal window:

#edit crontab
crontab -e

Then add the required file you want to execute prefaced by the following CRON instructions:

*/6 * * * * /path/to/desired/Python_version /path/to/executable/file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM