Schedule some jobs with php/python at some specific time without crontab
I have some irregular jobs to do(frequent and many), so I can't use the crontab.
for example:
- send an email at 10:20AM on July 22 2012
- post a article at 11PM tonight
- run a script at 9:50AM tomorrow.
I found the linux commond at
, but that can't be managed easily, otherwise, I search some message queue (like zeromq) and gearman, they can't do scheduled jobs or delayed job开发者_如何转开发s too.
Are there other solutions?
How about APScheduler?
import time
from datetime import datetime
from apscheduler.scheduler import Scheduler
# Schedule my_job for year, month, day, hour (out of 24), minute. Then wait.
sched = Scheduler()
sched.start()
def my_job(text): print text
job = sched.add_date_job(my_job, datetime(2011, 7, 11, 22, 04), ['hello'])
while True:
print datetime.now()
time.sleep(1)
Unfortunately, your choice is cron or manually manage sleep.
If you're using Django, however, this has already been accomplished for you.
精彩评论