# -*- coding: utf-8 -*- # Use this file to easily define all of your cron jobs. # # It's helpful to understand cron before proceeding. # http://en.wikipedia.org/wiki/Cron # # Learn more: http://github.com/fengsp/plan import os, sys from plan import Plan dirPath = os.path.dirname(os.path.realpath(__file__)) cron = Plan(path=dirPath) # examples # register one command, script or module # cron.command('command', every='1.day') # [1-60].minute [1-24].hour [1-31].day [1-12].month # cron.script('script.py', path='/web/yourproject/scripts', every='1.month') # cron.module('calendar', every='feburary', at='day.3') # 用法 python schedule_cron.py write/update/check/clear cron.script('collect_coins_for_dealers.py', every='1.hour',output= dict(stdout='/var/log/cronplan/collect_coins_stdout.log', stderr='/var/log/cronplan/collect_coins_stderr.log')) # 报表生成在collect动作之后 # 在00:30下执行一次脚本 cron.script('remove_consume_old.py', every='1.day', at='00:30', output= dict(stdout='/var/log/cronplan/make_rpt_into_db_stdout.log', stderr='/var/log/cronplan/make_rpt_into_db_stderr.log')) if __name__ == "__main__": runType = sys.argv[1] if len(sys.argv) > 1 else 'check' cron.run(runType)