From 82137089218342d0c54f9e714ae3fed4a28fa7c4 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sat, 30 May 2020 12:33:50 +0500 Subject: [PATCH] check if backup process actually running --- plogical/backupSchedule.py | 3 ++- plogical/backupScheduleLocal.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index f988fd75c..e58d9fe23 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -265,10 +265,11 @@ class backupSchedule: try: if os.path.exists(backupSchedule.runningPath): + pid = open(backupSchedule.runningPath, 'r').read() output = ProcessUtilities.outputExecutioner('ps aux') - if output.find('/usr/local/CyberCP/plogical/backupSchedule.py') > -1: + if output.find('/usr/local/CyberCP/plogical/backupSchedule.py') > -1 and output.find(pid) > -1: pid = open(backupSchedule.runningPath, 'r').read() print( '\n\nRemote backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % ( diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index 32b379757..345d7b610 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -30,9 +30,9 @@ class backupScheduleLocal: if os.path.exists(backupScheduleLocal.runningPath): output = ProcessUtilities.outputExecutioner('ps aux') + pid = open(backupScheduleLocal.runningPath, 'r').read() - if output.find('/usr/local/CyberCP/plogical/backupScheduleLocal.py') > -1: - pid = open(backupScheduleLocal.runningPath, 'r').read() + if output.find('/usr/local/CyberCP/plogical/backupScheduleLocal.py') > -1 and output.find(pid) > -1: print('\n\nLocal backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % (pid, pid)) return 0 else: