Running a python background script (Windows 7) to keep files updated

1.3k Views Asked by At

I have a list of websites I need to extract certain values from in order to keep a local .txt file up-to-date. Since the websites need to be checked at different time intervals I would prefer not to use Windows Task Manager but instead have a single script running continuously in the background, extracting the information from each website at each specified frequency (so the frequency for each website would be an input parameter) and keep the file updated.

I know how to extract the information from the websites but I don't know how to schedule the checks on the websites in an automated fashion and have the script run continuously in the background. Knowing how to stop it would be useful too. (I have Anaconda Python installed on Windows 7)

What is an efficient way of coding that? Thanks.

PS clarification: The script just needs to run as a background job once started and harvest some text from a number of predefined urls. So my questions are: a) How do I set it to run as a background job? A while loop? Something else? b) How do I make it return to a url to harvest the text at pre-specified intervals?

1

There are 1 best solutions below

0
On BEST ANSWER

Given that it doesn't need to be a hidden process and that the Windows Task scheduler is unsuitable (as you need to pick different recurrences), it sounds like you just want a simple Python process that will call your function to extract the data on an irregular but predetermined basis.

This sounds a lot like apscheduler (https://pypi.python.org/pypi/APScheduler/) to me. I've used it a lot in Linux and it's worked like a charm for cron-like features. The package docs say it is Cross platform and so might fit the bill.