summaryrefslogtreecommitdiffstats
path: root/src/retrace/abrt-retrace-cleanup
diff options
context:
space:
mode:
Diffstat (limited to 'src/retrace/abrt-retrace-cleanup')
-rwxr-xr-xsrc/retrace/abrt-retrace-cleanup60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/retrace/abrt-retrace-cleanup b/src/retrace/abrt-retrace-cleanup
deleted file mode 100755
index cbe1b818..00000000
--- a/src/retrace/abrt-retrace-cleanup
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-import time
-from retrace import *
-
-if __name__ == "__main__":
- now = int(time.time())
-
- logfile = "%s/cleanup.log" % CONFIG["LogDir"]
-
- try:
- log = open(logfile, "a")
- except IOError, ex:
- print "Error opening log file: %s" % ex
- sys.exit(1)
-
- log.write(time.strftime("[%Y-%m-%d %H:%M:%S] Running cleanup\n"))
-
- # kill tasks running > 1 hour
- ps_output = run_ps()
- running_tasks = get_running_tasks(ps_output)
- for pid, taskid, runtime in running_tasks:
- # ToDo: 5 = mm:ss, >5 = hh:mm:ss
- if len(runtime) > 5:
- log.write("Killing task %d running for %s\n" % (taskid, runtime))
- kill_process_and_childs(pid, ps_output)
-
- # kill orphaned tasks
- running_tasks = get_running_tasks()
- running_ids = []
- for pid, taskid, runtime in running_tasks:
- running_ids.append(taskid)
-
- for task in get_active_tasks():
- if not task in running_ids:
- log.write("Cleaning up orphaned task %d\n" % task)
- cleanup_task(task)
-
- # clean up old tasks
- try:
- files = os.listdir(CONFIG["SaveDir"])
- except OSError, ex:
- files = []
- log.write("Error listing task directory: %s\n" % ex)
-
- for filename in files:
- try:
- taskid = int(filename)
- except:
- continue
-
- dirpath = "%s/%s" % (CONFIG["SaveDir"], filename)
- if os.path.isdir(dirpath) and \
- (now - os.path.getatime(dirpath)) / 3600 >= CONFIG["DeleteTaskAfter"]:
- log.write("Deleting old task %s\n" % filename)
- call(["rm", "-rf", dirpath])
-
- log.close()