Use cron

71 views
Skip to first unread message

Martin Weissenboeck

unread,
Jul 22, 2020, 11:53:35 PM7/22/20
to web2py-users
I use web2py with nginx.Now I need cron . I have read, that habe to use "-Y" to activate it. But where is the place for this option, which configuration file?

Regards, Martin

AGRogers

unread,
Jul 23, 2020, 4:56:43 AM7/23/20
to web...@googlegroups.com
Sorry, can't help there. I have just started to use the Scheduler which is part of web2py. It was easy to setup and seems to work well. Is there a reason you can't use it? 

On Thu, 23 Jul 2020, 1:53 pm Martin Weissenboeck, <mwei...@gmail.com> wrote:
I use web2py with nginx.Now I need cron . I have read, that habe to use "-Y" to activate it. But where is the place for this option, which configuration file?

Regards, Martin

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CAMcwXCexnSYtV7X5VyW%3DGF6h8gcc1GPX%2BJBiZXBssK3H4C5PzA%40mail.gmail.com.

Martin Weissenboeck

unread,
Jul 23, 2020, 5:15:43 AM7/23/20
to web2py-users
Yes, I could use the scheduler. But it's a very small app (only 50 lines of code) and I wanted to learn how to use cron. 
Regards, Martin


Dave S

unread,
Jul 23, 2020, 5:29:48 AM7/23/20
to web2py-users


On Thursday, July 23, 2020 at 2:15:43 AM UTC-7, mweissen wrote:
Yes, I could use the scheduler. But it's a very small app (only 50 lines of code) and I wanted to learn how to use cron. 
Regards, Martin



What OS are you running on?

/dps
 
AGRogers <roge...@gmail.com> schrieb am Do., 23. Juli 2020, 10:56:
Sorry, can't help there. I have just started to use the Scheduler which is part of web2py. It was easy to setup and seems to work well. Is there a reason you can't use it? 

On Thu, 23 Jul 2020, 1:53 pm Martin Weissenboeck, <mwei...@gmail.com> wrote:
I use web2py with nginx.Now I need cron . I have read, that habe to use "-Y" to activate it. But where is the place for this option, which configuration file?

Regards, Martin

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web...@googlegroups.com.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web...@googlegroups.com.

Martin Weissenboeck

unread,
Jul 23, 2020, 6:53:41 AM7/23/20
to web2py-users
Ubuntu 16


To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5d7799dc-f285-48c9-9c34-0f4ef140881eo%40googlegroups.com.

Jose C

unread,
Jul 28, 2020, 4:53:18 AM7/28/20
to web2py-users
Just FYI, the web2py book states:

Try to avoid web2py cron, and use a background process instead. web2py cron can start too many Python instances and cause excessive memory usage.

Using scheduler means an additional long running process using up memory to monitor and manage the scheduler.

I'd recommend using your system crontab to run any background processes.  This can be invoked within the full web2py environment (if needed) from crontab as follows:

# Runs every 5 minutes.
*/5 * * * *  python3  /path/to/web2py.py --no_gui --no-banner -S <web2py_app_name> -M -R  /path/to/process/background_process.py

HTH,

Martin Weissenboeck

unread,
Jul 28, 2020, 5:30:36 AM7/28/20
to web2py-users
Thank you!
Martin


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.

Dave S

unread,
Jul 29, 2020, 11:00:28 AM7/29/20
to web2py-users


On Tuesday, July 28, 2020 at 1:53:18 AM UTC-7, Jose C wrote:
Just FYI, the web2py book states:

Try to avoid web2py cron, and use a background process instead. web2py cron can start too many Python instances and cause excessive memory usage.

Using scheduler means an additional long running process using up memory to monitor and manage the scheduler.


This is a problem for you?  I've had my scheduler running on AWS and Postgres for months without issue.  I actually have a second scheduler running in sqlite3 on the same machine.  No issue.
 
I'd recommend using your system crontab to run any background processes.  This can be invoked within the full web2py environment (if needed) from crontab as follows:

# Runs every 5 minutes.
*/5 * * * *  python3  /path/to/web2py.py --no_gui --no-banner -S <web2py_app_name> -M -R  /path/to/process/background_process.py

HTH,


Things that aren't python are better run via system cron, but the scheduler does a fine job for application-related pythonic work.

/dps
 

Jose C

unread,
Jul 29, 2020, 12:14:20 PM7/29/20
to web2py-users
Hi Dave,

This is a problem for you?  I've had my scheduler running on AWS and Postgres for months without issue.  I actually have a second scheduler running in sqlite3 on the same machine.  No issue.

Actually it becomes more of an issue if you are on a shared server with a limited shared resources plan.  Some limit number of long running processes as well as RAM.  Also there is the extra RAM used (my scheduler process started at 35Mb and slowly crept up over time). 

Things that aren't python are better run via system cron, but the scheduler does a fine job for application-related pythonic work.
 
My main problem was I had a few situations where my main scheduler process would just completely hang on a task (not the same one each time).  Never figured out the actual cause (no errors or tickets) but I had to write a script that would periodically (run from cron ;)  ) interrogate the scheduler worker tables for last run times and status and warn me if something was out of bounds.  Fiddling with worker statuses, etc. in the tables didn't resolve the issue - I had to kill -9 the process and restart it.  This is with 2.18.5 on CentOS.  When I refactored the code to move to python3 I moved to using crontab and, with my use case, not had a single problem since.  Each task runs independently and one 'glitch' does not stop all other tasks from running which caused me some grief.




Reply all
Reply to author
Forward
0 new messages