schedule_cron.py 1.3 KB

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