Commit d10d5139 authored by Łukasz Nowak's avatar Łukasz Nowak

- catch cron output and out them in var/log/cron-output


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45640 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5d8f62db
......@@ -257,6 +257,11 @@ class Recipe(BaseSlapRecipe):
def installCrond(self):
timestamps = self.createDataDirectory('cronstamps')
cron_output = os.path.join(self.log_directory, 'cron-output')
self._createDirectory(cron_output)
catcher = zc.buildout.easy_install.scripts([('catchcron',
__name__ + '.catdatefile', 'catdatefile')], self.ws, sys.executable,
self.bin_directory, arguments=[cron_output])[0]
cron_d = os.path.join(self.etc_directory, 'cron.d')
crontabs = os.path.join(self.etc_directory, 'crontabs')
self._createDirectory(cron_d)
......@@ -265,7 +270,7 @@ class Recipe(BaseSlapRecipe):
__name__ + '.execute', 'execute')], self.ws, sys.executable,
self.wrapper_directory, arguments=[
self.options['dcrond_binary'].strip(), '-s', cron_d, '-c', crontabs,
'-t', timestamps, '-f', '-l', '6', '-M', '/bin/true']
'-t', timestamps, '-f', '-l', '6', '-M', catcher]
)[0]
self.path_list.append(wrapper)
return cron_d
......
import os
import sys
import time
def catdatefile(args):
directory = args[0]
try:
suffix = args[1]
except IndexError:
suffix = '.log'
f = open(os.path.join(directory,
time.strftime('%Y-%m-%d.%H:%M.%s') + suffix), 'aw')
for line in sys.stdin.read():
f.write(line)
f.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment