check if backup process actually running

This commit is contained in:
Usman Nasir
2020-05-30 11:51:56 +05:00
parent 6769e83aa1
commit 5b012c7b96
2 changed files with 20 additions and 6 deletions

View File

@@ -29,9 +29,14 @@ class backupScheduleLocal:
try:
if os.path.exists(backupScheduleLocal.runningPath):
pid = open(backupScheduleLocal.runningPath, 'r').read()
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
output = ProcessUtilities.outputExecutioner('ps aux')
if output.find('/usr/local/CyberCP/plogical/backupScheduleLocal.py') > -1:
pid = open(backupScheduleLocal.runningPath, 'r').read()
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:
os.remove(backupScheduleLocal.runningPath)
writeToFile = open(backupScheduleLocal.runningPath, 'w')
writeToFile.write(str(os.getpid()))