Cron not working with Controller Functions

22 views
Skip to first unread message

Fran

unread,
Jul 16, 2009, 11:46:40 AM7/16/09
to web2py Web Framework
I'm using Trunk Source on Windows XP (Python-2.5.4)

I can get Cron working fine if I do:
*/5 * * * * root *applications/myapp/cron/
email_send.py
However this fails:
*/5 * * * * root *mycontroller/email_send

According to the docs, this should work:
http://web2py.com/examples/default/cron

email_send function is currently just:
import logging
logging.warn('email about to be sent!')

email_send.py is just:
import urllib
urllib.urlopen('http://%s/myapp/mycontroller/email_send' %
request.env.http_host).read()

Many thanks,
Fran.

AchipA

unread,
Jul 16, 2009, 12:03:03 PM7/16/09
to web2py Web Framework
Depending on the cron mode, you likely won't see the logging.warn as
it is executed in a different process when called from cron. When
called from the script, the warn is executed in the 'main' process and
hence you can see it. So that in itself does not mean anything. When
debugging cron functions, first make sure it works by calling it via -
S app/contr/func as debug output will be hard to obtain straight from
subprocesses.

Fran

unread,
Jul 16, 2009, 1:30:59 PM7/16/09
to web2py Web Framework
On Jul 16, 5:03 pm, AchipA <attila.cs...@gmail.com> wrote:
> Depending on the cron mode, you likely won't see the logging.warn as
> it is executed in a different process when called from cron. When
> called from the script, the warn is executed in the 'main' process and
> hence you can see it. So that in itself does not mean anything.

Right yes, sorry - I reduced the call to that simple function when my
1st attempts failed.
The real call is an email send using mail.send()
This works fine, as a Hard Cron, if I'm running the Widget & using the
wrapper script to call it.

> When
> debugging cron functions, first make sure it works by calling it via -
> S app/contr/func as debug output will be hard to obtain straight from
> subprocesses.

The function itself works fine from the Web UI, via the CLI called
like this & via the wrapper script called by Cron.
It fails when trying to call from Cron direct.

Another cron issue I have is that even the wrapper script file isn't
working when running as a Windows Service (http://mdp.cti.depaul.edu/
AlterEgo/default/show/77).
- even if I keep accessing the server, so it's not just rveerting to
Soft mode.

Any further tips on debugging either of these issues would be
welcome :)

F

Fran

unread,
Jul 16, 2009, 1:55:09 PM7/16/09
to web2py Web Framework
On Jul 16, 6:30 pm, Fran <francisb...@googlemail.com> wrote:
> Another cron issue I have is that even the wrapper script file isn't
> working when running as a Windows Service (http://mdp.cti.depaul.edu/
> AlterEgo/default/show/77).
> - even if I keep accessing the server, so it's not just rveerting to
> Soft mode.

I can see that the file web2py/applications/admin/cron/cron.master is
updated when I access a page, but not otherwise...does this suggest
that the service can only do softcron?

PS I sent a patch to Masimo to fix the typo in 'horly' (not that this
affects me)

F

AchipA

unread,
Jul 17, 2009, 8:21:01 AM7/17/09
to web2py Web Framework
No idea about service, I have not tested it separately. Looking at
widget.py, however, I saw an unrelated potential problems though, so
I'll test it a bit anyway. Will send the patch to Massimo and/or
report back regarding to findings on service mode.
Reply all
Reply to author
Forward
0 new messages