python time

ecu_jon hayesjdno3 at yahoo.com
Sun Mar 20 21:19:12 EDT 2011


I'm working on a script that will run all the time. at time specified
in a config file, will kick-off a backup.
problem is, its not actually starting the job. the double while loop
runs, the first comparing date works. the second for hour/min does
not.

#python file
import os,string,,time,getpass,ConfigParser
from datetime import *
from os.path import join, getsize
from time import strftime,localtime

config = ConfigParser.ConfigParser()
config.read("config.ini")
source = config.get("myvars", "source")
destination = config.get("myvars", "destination")
date = config.get("myvars", "date")
time = config.get("myvars", "time")
str_time=strftime("%H:%M",localtime())

while datetime.now().weekday() == int(date):
    while str_time == time:
        print "do it"

#config file
#change the time variable to "now"+a min or two to observe
#this needs to be where ever the actual python script is
[myvars]
#only set source if you want it to be different
source: c:\users\jon
destination: \\mothera\jon\
#what day of the week to perform backup?where Monday is 0 and Sunday
is 6
date: 6
#time to start
time: 21:02



More information about the Python-list mailing list