scheduled tasks - Scheduler on Debian -


upstart not exist in debian on beaglebone , not want mess that. there script developed in https://github.com/web2py/web2py/blob/master/scripts/setup-scheduler-centos.sh uses chkconfig add service start up. chkconfig not exist in debian. tried modify script , use update-rc.d, attempts failed. want run periodic tasks , suggestion welcome , appreciated. know celery found massimo's argument scheduler convincing , wanted use it. way, main drawbacks of web2py cron? should try use that?

if want run simple periodic background tasks suggest using web2py's "homemade task queues." using following terminal command give python script access application's models, while running in background (you can use cron schedule command run on startup):

nohup python web2py.py -s myapp -m -r applications/myapp/private/myscript.py 

your custom script (usually kept in /private folder of application) may this:

## in file /myapp/private/mail_queue.py import time while true:     rows = db(db.queue.status=='pending').select()     row in rows:         if mail.send(to=row.email,             subject=row.subject,             message=row.message):             row.update_record(status='sent')         else:             row.update_record(status='failed')         db.commit()     time.sleep(60) # check every minute 

this sample script web2py docs checks pending messages (every 60 seconds) in db , sends out email. note, script should periodic while loop, , unlike controllers, must use db.commit() after making changes db.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -