我有一个job.py
包含以下代码的。
import datetime
import logging
import sys
import os
from apscheduler.scheduler import Scheduler
from src.extractors.pExtractor import somejob
def run_job():
start = datetime.datetime.now()
logging.debug('Proposal extraction job starting')
somejob.main()
end = datetime.datetime.now()
duration = end - start
logging.debug('job completed , took ' + str(duration.seconds) + ' seconds')
def main():
logging.basicConfig(filename='/tmp/pExtractor.log', level=logging.DEBUG,format='%(levelname)s[%(asctime)s]: %(message)s')
sched = Scheduler()
sched.start()
sched.add_interval_job(run_job, minutes=2)
if __name__ == '__main__':
main()
- 当我在命令提示符下运行它时,它会立即退出:
INFO[2012-04-03 13:31:02,825]:启动线程池,核心线程数为 0,最大线程数为 20 INFO[2012-04-03 13:31:02,827]:调度程序已启动 INFO[2012-04-03 13: 31:02,827]:将作业“run_job(触发器:cron[minute='2'],下次运行时间:2012-04-03 14:02:00)”添加到作业存储“默认”信息 [2012-04-03 13:31:02,828]:关闭线程池
- 我怎样才能让这个作为守护进程运行?