diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/PilotLoggingAgent.py b/src/DIRAC/WorkloadManagementSystem/Agent/PilotLoggingAgent.py index 1708afe4dea..5fda3320a24 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/PilotLoggingAgent.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/PilotLoggingAgent.py @@ -175,13 +175,13 @@ def clearOldPilotLogs(self, pilotLogPath): files = os.listdir(pilotLogPath) seconds = int(self.clearPilotsDelay) * 86400 currentTime = time.time() - os.chdir(pilotLogPath) for file in files: - modifTime = os.stat(file).st_mtime + fullpath = os.path.join(pilotLogPath, file) + modifTime = os.stat(fullpath).st_mtime if modifTime < currentTime - seconds: - self.log.debug(f" Deleting old log : {file}") + self.log.debug(f" Deleting old log : {fullpath}") try: - os.remove(file) + os.remove(fullpath) except Exception as excp: - self.log.exception(f"Cannot remove an old log file after {file}", lException=excp) + self.log.exception(f"Cannot remove an old log file after {fullpath}", lException=excp)