def execute(self):
        #currentPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

        startTime = time.time()
        print("monkey开始时间:%s" % (datetime.datetime.now())).decode("utf-8")
        monkeyThreadInstance = MonkeyThread(self.logPath, self.deviceId,
                                            self.pkgName)
        utils.forceStop(self.pkgName, self.deviceId)
        #workPath = self.monkeyLogPath#os.path.join(self.monkeyLogPath, "logs", self.pkgName+getCurrentTime())
        #os.mkdir(workPath)
        if not os.path.exists(self.logPath):
            os.makedirs(self.logPath)

        try:
            monkeyThreadInstance.start()

            while True:
                endTime = time.time()
                # 清除之前的日志
                #                 utils.clearLog(self.deviceId)

                if (endTime - startTime) < self.minutes * 60:
                    if monkeyThreadInstance.is_alive():
                        time.sleep(10)
                    else:
                        #self.collect()
                        #self.analyse()

                        utils.forceStop(self.pkgName, self.deviceId)

                        #workPath = self.monkeyLogPath#os.path.join(currentPath, "logs", self.pkgName+getCurrentTime())
                        #os.mkdir(workPath)
                        if not os.path.exists(self.logPath):
                            os.makedirs(self.logPath)

                        monkeyThreadInstance = MonkeyThread(
                            self.deviceId, self.pkgName)
                        monkeyThreadInstance.start()
                else:
                    print("monkey结束时间:%s" %
                          (datetime.datetime.now())).decode("utf-8")
                    Monkey.terminateMonkey(self.deviceId)

                    self.collect()
                    self.analyse()
                    break
        except Exception, e:
            print("Monkey Exception:" % (e))
            print("Monkey traceback:" % (traceback.print_exc()))
            traceback.print_exc()
            Monkey.terminateMonkey(self.deviceId)
            self.collect()
            self.analyse()