Cron job every 30 seconds

1,717 views
Skip to first unread message

melmg

unread,
Nov 26, 2013, 3:55:16 PM11/26/13
to web...@googlegroups.com
Is is possible to set up a cron job to run every 30 seconds instead of a minute? I have a function that does an HTTP GET request to retrieve some values from another server (a small server running on a microcontroller) and then saves those values in the database. I want to run this function every 30 seconds in the background. 

Thank you for the help!

Vinicius Assef

unread,
Nov 27, 2013, 5:39:51 AM11/27/13
to web2py
Linux standard cron doesn't allow it.

Bu you can have a process that enters a loop, do something, sleeps for
n seconds e try again.
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Brian M

unread,
Nov 27, 2013, 9:20:06 PM11/27/13
to web...@googlegroups.com
web2py's scheduler will let you set the repeat period in seconds so you could probably do 30 seconds that way.

Javier Pepe

unread,
Nov 28, 2013, 6:22:28 AM11/28/13
to web...@googlegroups.com
You can add cron job which sleep

* * * * * sleep  0;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py
* * * * * sleep 10;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py
* * * * * sleep 20;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py
* * * * * sleep 30;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py
* * * * * sleep 40;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py
* * * * * sleep 50;/usr/local/apps/web2py/applications/sipacweb/private/run procesos.py

This process run every ten seconds.





--

Massimo Di Pierro

unread,
Nov 28, 2013, 8:33:48 AM11/28/13
to web...@googlegroups.com
Please use the scheduler, not cron. Cron must die. 

Leonel Câmara

unread,
Nov 28, 2013, 11:53:55 AM11/28/13
to web...@googlegroups.com
Is the time critical? Do you have control/can program the server in the microcontroller?

It seems to me as this should be reversed. Instead of you polling the microcontroller, the microcontroller should be sending you new data, either when it receives it or in batches.
Reply all
Reply to author
Forward
0 new messages