I'm running web2py locally with Windows 7 and live on a Linux Ubuntu server and I haven't been able to get my cron job to run in either.
My crontab looks like this:
*/1 * * * * root *autoemail/send_autoemails
and my function works fine when called manually. It also ends with
db.commit()
Other than that I don't know what else to do get it working although I really didn't understand all of the web2py book section on Cron, specifically when it came to soft/hard/external cron and all of that.
I saw a web2py thread that perhaps cron was going to be replaced?
Perhaps that has something to do with this? Is there something else I need to do to configure cron before it will work?
Any ideas about how I can troubleshoot this are greatly appreciated.
On this moment web2py is changing from Cron to Scheduler, with newer web2py versions Cron is disabled by default.
You can use your function with the Scheduler, putting it into a model file and passing it to the scheduler creator class, in order to enable a new Scheduler instance with it:
# New File applications/yourapp/models/zfunctions.py
#
def send_autoemails():
...
...#Your code here
...
...
from gluon.scheduler import Scheduler
Scheduler(db,dict(yourfunction=send_autoemails))
After that you can add a new job simply from the web2py db admin interface,
under db.task_scheduled you must click on insert new task_scheduled and set
period to run, repeats, timeouts, enable, disable, etc....
Here are some info about it: http://web2py.com/book/default/chapter/04#Scheduler-(experimental)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With