박선빈
박선빈

Reputation: 21

i want your help abut program to run automatically every 12 hours

I'm doing a tweepy crawling. I want the program to run automatically every 12 hours Could you tell me the syntax? I'm doing it with Python, and I have all the tweepy crawling code.

Upvotes: 2

Views: 69

Answers (2)

abdulla-alajmi
abdulla-alajmi

Reputation: 501

You can use "schedule" library

to install, on terminal enter:

pip install schedule

here is an example of the code you want:

#!/usr/bin/python

import schedule
import time

def job():
    print("I am doing this job!")

schedule.every(12).hours.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

or you can read the documents to see the other functions Click Here

good luck!

Upvotes: 0

strash
strash

Reputation: 1321

You can try executing/calling your program by the command line interface and schedule a task using the embedded in windows- Windows Scheduler. There are many alternatives but that is the easiest I found when I did such task few months ago.

Upvotes: 1

Related Questions