谷歌云中的Cron工作显示状态失败[重复]

时间:2022-08-22 10:54:28

This question already has an answer here:

这个问题在这里已有答案:

I am currently working in Google clouds and i have deployed my python application in Google app engine. now i want to schedule tasks in it. i have read it. Google clouds is doing this through cron jobs. i have written a very basic cron and trying to run it. but every time it failing. can anyone please tell me what is going wrong. here is my app.yaml

我目前正在使用Google云,我已经在Google应用引擎中部署了我的python应用程序。现在我想在其中安排任务。我读过它。谷歌云正在通过cron工作做到这一点。我写了一个非常基本的cron并尝试运行它。但每次失败。任何人都可以告诉我出了什么问题。这是我的app.yaml

handlers:
- url: /laptop/
  script: file.py
  login: admin

and my cron.yaml file is

我的cron.yaml文件是

cron:
- description: daily summary job
  url: /laptop
  target: beta
  schedule: every 24 hours

my file which i want to run is in myproject/laptop/file.py

我要运行的文件位于myproject / laptop / file.py中

and my file.py is only printing my name (just for testing purpose)

而我的file.py只打印我的名字(仅用于测试目的)

print "Amad";
print "testing"

can anybody tell me, how can i run this file on Google app engine.

任何人都可以告诉我,我怎么能在谷歌应用引擎上运行这个文件。

when i run this cron on task queues it gives me error like this. 谷歌云中的Cron工作显示状态失败[重复]

当我在任务队列上运行此cron时,它给出了这样的错误。

please refer me some tutorial where i can successfully run it. i have waste a lot of my time on it. Any help or suggestions are highly appreciated.

请参考我的一些教程,我可以成功运行它。我浪费了很多时间在上面。任何帮助或建议都非常感谢。

2 个解决方案

#1


0  

You can view all your apps logs including any error messages by clicking the "hamburger" button in the top left and selecting "Logging".

您可以通过单击左上角的“汉堡包”按钮并选择“记录”来查看所有应用程序日志,包括任何错误消息。

There you should see the cause of the error in your cron handler.

你应该在cron处理程序中看到错误的原因。

Possible problem: perhaps your handler should not end with /

可能的问题:也许你的处理程序不应该以/结尾

#2


0  

I think you might need to set up your file.py to be similar to a regular main.py (can't tell if you've done so but based on your contents of file.py it doesn't seem so) Copy and paste the sample tutorial code from https://cloud.google.com/appengine/docs/standard/python/quickstart, and put your print statements in the get method

我认为你可能需要将你的file.py设置为类似于常规的main.py(不知道你是否已经这样做但是根据你的file.py的内容它似乎不是这样)复制和粘贴https://cloud.google.com/appengine/docs/standard/python/quickstart中的示例教程代码,并将您的print语句放在get方法中

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        print "Amad";
        print "testing"


app = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)

This should solve your problem if the other files are ok, like app.yaml (refer to link for sample code on this)

如果其他文件没问题,这应该可以解决您的问题,例如app.yaml(请参阅此示例代码的链接)

#1


0  

You can view all your apps logs including any error messages by clicking the "hamburger" button in the top left and selecting "Logging".

您可以通过单击左上角的“汉堡包”按钮并选择“记录”来查看所有应用程序日志,包括任何错误消息。

There you should see the cause of the error in your cron handler.

你应该在cron处理程序中看到错误的原因。

Possible problem: perhaps your handler should not end with /

可能的问题:也许你的处理程序不应该以/结尾

#2


0  

I think you might need to set up your file.py to be similar to a regular main.py (can't tell if you've done so but based on your contents of file.py it doesn't seem so) Copy and paste the sample tutorial code from https://cloud.google.com/appengine/docs/standard/python/quickstart, and put your print statements in the get method

我认为你可能需要将你的file.py设置为类似于常规的main.py(不知道你是否已经这样做但是根据你的file.py的内容它似乎不是这样)复制和粘贴https://cloud.google.com/appengine/docs/standard/python/quickstart中的示例教程代码,并将您的print语句放在get方法中

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        print "Amad";
        print "testing"


app = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)

This should solve your problem if the other files are ok, like app.yaml (refer to link for sample code on this)

如果其他文件没问题,这应该可以解决您的问题,例如app.yaml(请参阅此示例代码的链接)