Python scheduler example

import sched
import time
import datetime
import os
 
__fifteenMins = 15 * 60
__cmd = "sqlplus scott/tiger@oradb @c:\madan\sql\update_rows.sql"
s=sched.scheduler(time.time, time.sleep)
def print_time():
	try:
		print "From print_time", datetime.datetime.now()
	except:
		print "Abort print_time()"
		pass
 
def print_some_times():
	try:
		print datetime.datetime.now()
		s.enter(__fifteenMins, 1, print_time, ())
		s.run()
		os.system(__cmd)
		print_some_times()
	except:
		print "Abort"
		pass
 
print_some_times()

pythonsched.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0