php - Is Cron the only method to run scheduled tasks? -
is cron(or derivatives) method run scheduled programming tasks? example:
- charge clients' credit card @ 3 days before x
- send e-mail 6 hours time x
- execute xyz command every hour
is there resource/books teach how implement these features in clean way(python, ruby(or ror), python)?
my current dirty method have wrapper script in crontab running every minute check if tasks should run. don't this. prefer method can programatically implement scheduled tasks.
for python can use celery
for example executing command every hour this:
from celery.task.schedules import crontab celery.decorators import periodic_task @periodic_task(run_every=crontab(hour=3)) def every_three_hour(): print("this runs every 3 hour") and execting 3 hours look:
from datetime import datetime yourtask.apply_async(args=[some, args, here], eta=datetime.now()+datetime.timedelta(hours=3))
Comments
Post a Comment