简体   繁体   中英

How to run python script once in a day that is creating back-up copy of network dir?

I want to take back-up copy of my network dirs once in a day on specified time, Below is the code of my current work by which i am running it manually.

So i want to do this manual work as windows service which creates a back-up copy of specified network dir on particular time.

import tarfile
import datetime

def backup_htmls():
    tar = tarfile.open('./InputHTML_bc/'+datetime.datetime.now().strftime('%b_%d_%Y_%H_%M_%S')+".tar.gz", "w:gz")
    tar.add('\\\\192.168.211.65\\shared\\InputHTML\\', arcname="Backup_Tar")
    tar.close()

I have the reference of how to run it as a windows service;

i just want how can i run this job once in a day on particular time(for example if i pass time as a parameter to python function and it will execute it once for that day.. or any other way you can do it.. in pythonic way)??? i know it will be very easy but i am not getting the idea from where i can start anyway of doing it???

Here's a recipe that shows you how to create a windows service using Python:

http://code.activestate.com/recipes/576451-how-to-create-a-windows-service-in-python/

There is this: http://runasservice.sourceforge.net/

Which was referenced in this similar question:

Run batch file as a Windows service

And as a batch file can start your python up....

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