帮助第一个 web2py Cron 任务正常工作

发布于 2024-12-06 09:05:25 字数 438 浏览 0 评论 0原文

我在 Windows 7 本地运行 web2py,并在 Linux Ubuntu 上运行 服务器,我也无法让我的 cron 作业在其中运行。

我的 crontab 看起来像这样:

*/1 * * * * root *autoemail/send_autoemails 

并且我的函数在手动调用时工作正常。它还以

db.commit()

除此之外我不知道还能做什么来让它工作,尽管我 真的不明白 web2py 书上关于 Cron 的所有部分, 特别是当涉及到软/硬/外部 cron 等等时。

我看到一个 web2py 线程,也许 cron 将被替换?

也许这与此有关?在 cron 工作之前我还需要做些什么来配置它吗?

非常感谢任何关于如何解决此问题的想法。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隐诗 2024-12-13 09:05:25

此时,web2py 正在从 Cron 更改为 Scheduler,较新的 web2py 版本 Cron 默认情况下处于禁用状态。

您可以将您的函数与 Scheduler 一起使用,将其放入模型文件中并将其传递给调度程序创建者类,以便使用它启用新的 Scheduler 实例:

# New File applications/yourapp/models/zfunctions.py
#
def send_autoemails():
    ...
    ...#Your code here
    ...
    ...

from gluon.scheduler import Scheduler
Scheduler(db,dict(yourfunction=send_autoemails)) 

之后,您可以简单地从 web2py 添加新作业数据库管理界面,
在 db.task_scheduled 下,您必须单击插入新的 task_scheduled 并设置
运行周期、重复、超时、启用、禁用等...
以下是有关它的一些信息: http://web2py.com/book/default /chapter/04#Scheduler-(实验

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文