2017-04-21 4 views
-3

이 스크립트를 작성하여 파이썬으로 텍스트 파일을 업로드했지만이 스크립트를 수정하여 5 분마다이 파일을 업로드하고 싶습니다. 어떻게해야합니까?스크립트를 반복하고 5 분마다 파일 업로드

import ftplib 
 
import win32api 
 
import os 
 

 
sftp = ftplib.FTP('ftp.microsoft.com','test','test') # Connect 
 
sftp.cwd("test") 
 

 
fp = open('test.txt','rb') # file to send 
 
sftp.storbinary('test.txt', fp) # Send the file 
 

 
fp.close() # Close file and FTP 
 
sftp.quit()

+0

사용 크론 http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/ – Mateusz

답변

0

파이썬은 이벤트 스케줄링을위한 schedmodule 있습니다.

import sched, time 
s = sched.scheduler(time.time, time.sleep) 
def do_something(sc): 
    print "Doing stuff..." 
    # scheduling calls 
    s.enter(300, 1, do_something, (sc,)) 

# initial call to function 
s.enter(60, 1, do_something, (s,)) # (delay, priority, action, argument) 
s.run()