Skip to content
Snippets Groups Projects
Commit 8d2959f6 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix clean cron def

parent 9aada461
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,14 @@ class Crons:
self.init_clean_cron()
self.init_launch_local_cron()
@staticmethod
def _get_python_exec():
pyexec = sys.executable
match = re.match(r"^(.+)/lib/(python[^/]+)/((site-packages/bin/python)|())$", pyexec)
if match:
pyexec = "%s/bin/%s" % (match.group(1), match.group(2))
return pyexec
def init_clean_cron(self):
"""
Clean cron is launched at 1h00am each day
......@@ -41,8 +49,9 @@ class Crons:
clean_time = self.config.cron_clean_time
clean_freq = self.config.cron_clean_freq
if self.base_dir is not None:
job = self.my_cron.new(sys.executable +
" {0}/bin/clean_jobs.py > {0}/clean.log 2>&1".format(self.config.log_dir),
job = self.my_cron.new(self._get_python_exec() +
" {0}/bin/clean_jobs.py > {1}/clean.log 2>&1".format(self.base_dir,
self.config.log_dir),
comment="dgenies")
job.day.every(clean_freq)
job.hour.on(clean_time[0])
......@@ -57,10 +66,7 @@ class Crons:
:return:
"""
if self.base_dir is not None:
pyexec = sys.executable
match = re.match(r"^(.+)/lib/(python[^/]+)/((site-packages/bin/python)|())$", pyexec)
if match:
pyexec = "%s/bin/%s" % (match.group(1), match.group(2))
pyexec = self._get_python_exec()
logs = os.path.join(self.config.log_dir, "local_scheduler.log") if self.debug else "/dev/null"
job = self.my_cron.new("{0}/bin/start_local_scheduler.sh {0} {1} {2} {3} > /dev/null 2>&1 &".
format(self.base_dir, pyexec, self.local_scheduler_pid_file, logs),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment