CRONTAB Issues - cannot get it to run?

88 views
Skip to first unread message

Jim Houchens

unread,
Apr 14, 2013, 1:57:37 PM4/14/13
to web...@googlegroups.com

I hope one of you folks can help - I'm still a little green with web2py and python, but am trying to get the CRON to work to run a script in our application.

 

I've been scouring the web for examples, but wonder if our version is setup to utilize it. 

I've tried both the unix cron, and the web2py crontab, but can't get either to execute my test script.
 
My latest attempt via the applications crontab :
#crontab
0-59/1  *  *  *  * root *test_cron_jfh/main

 

I've tried with and w/o the wsgihandler.py variable of SOFTCRON = True (and False - restarting apache in between)
 
I've tried running it from the unix OS with python as in :
 
$python2.7 /home/ameteq/webapps/web2py/web2py/web2py.py -S sms_test_protocol -M -R /home/ameteq/webapps/web2py/web2py/applications/sms_test_protocol/controllers/test_cron_jfh.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.4 (2011-12-14 14:46:14) stable
Database drivers available: SQLite3, pymysql, PostgreSQL
$
 

Have also tried to run a  script from the unix command-line with just web2py.py :

      ./web2py.py -S sms_test_protocol -R *applications/sms_test_protocol/test_cron_jfh/ins_err

 

      Traceback (most recent call last):

        File "./web2py.py", line 16, in ?

          import gluon.widget

        File "/home/ameteq/webapps/web2py/web2py/gluon/__init__.py", line 15, in ?

          from globals import current

        File "/home/ameteq/webapps/web2py/web2py/gluon/globals.py", line 21, in ?

          from html import xmlescape, TABLE, TR, PRE, URL

        File "/home/ameteq/webapps/web2py/web2py/gluon/html.py", line 30, in ?

          from utils import web2py_uuid, hmac_hash

        File "/home/ameteq/webapps/web2py/web2py/gluon/utils.py", line 12, in ?

          import hashlib

      ImportError: No module named hashlib

 

 

If you are familiar with this, can you point me in the right direction?  I've tried several recommendadtions from the web, but so far, no luck.

If you can help, it would be greatly appreciated.

 

Thanks,

 

-jim

Richard Vézina

unread,
Apr 15, 2013, 9:51:04 AM4/15/13
to web2py-users
Jim,

1.99.4 is pretty old, you should update...

It may be more handy if you try to find a old version of the book, I don't know but since web2py is progressing very rapidly it may be possible that the way to use crontab has change... It could explain your problem...

Richard


 

-jim

--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Niphlod

unread,
Apr 15, 2013, 10:09:13 AM4/15/13
to
hi, you're mix/matching the available options.
First of all, if your system has an available cron, use that. web2py's cron is not as accurate as unix one.
If you want to leverage cron, at least read the section in the book that speaks of it
http://web2py.com/books/default/chapter/29/04#Cron

If you instead have a python script that needs to be run within the web2py environment of your app (so you can access db, etc etc etc), you can use with the "standard" cron this syntax

python web2py.py -M -S yourappname -R /path/to/scriptname.py

Remember that * and ** used before the command  (like your example -R *applications/sms_test_protocol/test_cron_jfh ) has no implementation in the system cron. Those asterisks are only available in web2py's cron (they are shortcuts to enable -S and -M respectively on the "runner" command).


James F Houchens

unread,
Apr 15, 2013, 1:28:34 PM4/15/13
to web...@googlegroups.com
Thanks for your help   Def read the book but struggled a bit. 

I ended up using the unix cron tab and got it working. 

Thanks again for taking the time to respond.  

Sent from my iPhone

On Apr 15, 2013, at 10:08 AM, Niphlod <nip...@gmail.com> wrote:

hi, you're mix/matching the available options.
First of all, if your system has an available cron, use that. web2py's cron is not as accurate as unix one.
If you want to leverage cron, at least read the section in the book that speaks of it
http://web2py.com/books/default/chapter/29/04#Cron

If you instead have a python script that needs to be run within the web2py environment of your app (so you can access db, etc etc etc), you can use with the "standard" cron this syntax

python web2py.py -M -S yourappname -R /path/to/scriptname.py

Remember that * and ** used before the command  (like your example -R *applications/sms_test_protocol/test_cron_jfh ) are only available in web2py's cron (they are shortcuts to enable -S and -M respectively).


--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/-aKve0DnTbg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

James F Houchens

unread,
Apr 15, 2013, 1:28:46 PM4/15/13
to web...@googlegroups.com
Thanks for your help   Def read the book but struggled a bit. 

I ended up using the unix cron tab and got it working. 

Thanks again for taking the time to respond.  

Sent from my iPhone
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/-aKve0DnTbg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages