php - Is Cron the only method to run scheduled tasks? -


is cron(or derivatives) method run scheduled programming tasks? example:

  1. charge clients' credit card @ 3 days before x
  2. send e-mail 6 hours time x
  3. 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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -