Python timed execution script program

Add the program running command to the environment variable under cmd. The program can be started at any position under cmd to execute the command. According to the scheduling package, set the execution interval. When the interval reaches the scheduling tool requirements, trigger the execution of the command , So as to achieve timing tasks and automated scripts.

Load package

pip install  schedule

Execute program code

import schedule


def job():
    import os

    def fun():
        os.system("python  /tandelindata/ETL_code/ftp_dowload_local.py")
        #os.system("Rscript  /tandelindata/ETL_code/R_text_mysql.R")

    fun()


schedule.every(2).seconds.do(job)

if __name__ == '__main__':
    while True:
        schedule.run_pending()

Guess you like

Origin blog.csdn.net/tandelin/article/details/106589907