#!/usr/bin/env python #coding: utf-8 -*- """ time rotate, minute, NOT set multiprocess no mail """ import commands import os import time from multiprocessing import Process,Value,Lock from xlogging import log log.setConfig(module_name='case04',ro_rotateby=2, ro_when='m', ro_backupcount=4,logfile='test_case04.log',multiprocess=0,viamail=0,mailaddr='*****@*****.**') def log_a(): while True: log.debug('''a''') time.sleep(1) def log_b(): while True: log.debug('''b''') time.sleep(1) if __name__ == '__main__': pida = Process(target=log_a,args=()) pidb = Process(target=log_b,args=())
""" time rotate, midnight, set multiprocess has mail """ import commands import os import time from multiprocessing import Process, Value, Lock from xlogging import log log.setConfig( module_name="case05", ro_rotateby=2, ro_when="midnight", ro_backupcount=4, logfile="test_case05.log", multiprocess=1, viamail=1, mailaddr="*****@*****.**", ) def log_a(): while True: log.debug("""a""") time.sleep(1) def log_b(): while True: log.debug("""b""")
from lib_crawl import do_crawl from crawl_exception import RobotCheckError, OperationError SQL_ALL_ASIN = """ SELECT asin FROM `crawl_asin` ORDER BY `id` ASC """ SQL_INSERT_STAT = """ INSERT into crawl_asin_statistic VALUES (NULL, '%s', '%s', '%s'); """ Max_Num_Msg = 'exceeded the maximum number of items' START_HOUR = 15 log.setConfig(module_name='crawl_amazon_forever', ro_rotateby=2, ro_when='midnight', \ ro_backupcount=4,logfile='crawl_amazon_forever.log') if __name__ == '__main__': today_done = 0 conn = None while True: current_time = time.localtime(time.time()) if current_time.tm_hour != START_HOUR: if today_done == 1 and current_time.tm_hour > START_HOUR: today_done = 0 time.sleep(30) elif today_done == 1: time.sleep(30) else: #print 'Start do Crawl at ', datetime.datetime.now() log.info('Start do Crawl at %s' % str(datetime.datetime.now()))
#!/usr/bin/env python #coding: utf-8 -*- """ file rotate, NOT set multiprocess no mail """ import commands import os import time from multiprocessing import Process,Value,Lock from xlogging import log log.setConfig(module_name='case03',ro_rotateby=1,ro_backupcount=4,ro_maxsize=1024,logfile='test_case03.log',multiprocess=0,viamail=0,mailaddr='*****@*****.**') def log_a(): while True: log.debug('''a''') time.sleep(1) def log_b(): while True: log.debug('''b''') time.sleep(1) if __name__ == '__main__': pida = Process(target=log_a,args=()) pidb = Process(target=log_b,args=())