#-*-coding:utf-8-*-
from apscheduler.scheduler import Scheduler
def job_function(a):
print a
if __name__ == '__main__':
hello = 'hello world'
sched = Scheduler(daemonic=False) # 注意这里,要设置 daemonic=False
sched.add_cron_job(job_function, day_of_week='mon-fri', hour='*', minute='0-59', second='*/5', args=[hello]) # args=[] 用来给job函数传递参数
sched.start()
# ----------- 源码 -------------------------------
# def add_cron_job(self, func, year=None, month=None, day=None, week=None,
# day_of_week=None, hour=None, minute=None, second=None,
# start_date=None, args=None, kwargs=None, **options):
# """
# Schedules a job to be completed on times that match the given
# expressions.
#
# :param func: callable to run
# :param year: year to run on
# :param month: month to run on
# :param day: day of month to run on
# :param week: week of the year to run on
# :param day_of_week: weekday to run on (0 = Monday)
# :param hour: hour to run on
# :param second: second to run on
# :param args: list of positional arguments to call func with
# :param kwargs: dict of keyword arguments to call func with
# :param name: name of the job
# :param jobstore: alias of the job store to add the job to
# :param misfire_grace_time: seconds after the designated run time that
# the job is still allowed to be run
# :return: the scheduled job
# :rtype: :class:`~apscheduler.job.Job`
# """
#