2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

Store log in a file for auto upgrade and backup, fix #35

This commit is contained in:
Pratik Vyas 2014-07-25 12:44:02 +05:30
parent cd51df6a4c
commit 78ba5f2c4a

View File

@ -87,13 +87,15 @@ def get_bench_dir(bench='.'):
def setup_auto_update(bench='.'):
logger.info('setting up auto update')
add_to_crontab('0 10 * * * cd {bench_dir} && {bench} update --auto'.format(bench_dir=get_bench_dir(bench=bench),
bench=os.path.join(get_bench_dir(bench=bench), 'env', 'bin', 'bench')))
add_to_crontab('0 10 * * * cd {bench_dir} && {bench} update --auto >> {logfile} 2>&1'.format(bench_dir=get_bench_dir(bench=bench),
bench=os.path.join(get_bench_dir(bench=bench), 'env', 'bin', 'bench'),
logfile=os.path.join(get_bench_dir(bench=bench), 'logs', 'auto_update_log.log')))
def setup_backups(bench='.'):
logger.info('setting up backups')
add_to_crontab('0 */6 * * * cd {sites_dir} && {frappe} --backup all'.format(sites_dir=get_sites_dir(bench=bench),
frappe=get_frappe(bench=bench)))
add_to_crontab('0 */6 * * * cd {sites_dir} && {frappe} --backup all >> {logfile} 2>&1'.format(sites_dir=get_sites_dir(bench=bench),
frappe=get_frappe(bench=bench),
logfile=os.path.join(get_bench_dir(bench=bench), 'logs', 'backup.log')))
def add_to_crontab(line):
current_crontab = read_crontab()