这个问题在这里已有答案:
我正在尝试使用the cron functionality在Google Cloud上部署的服务器中添加计划任务 . 在部署之前,我'm testing in localhost, so I'配置了一个简单的cron.yaml文件,如下所示:
#cron file
cron:
- description: Testing cron functionality
url: /task
schedule: every 1 minutes
还有一个简单的 endpoints ,如下所示:
#myblueprint.py
#from ... import ....
from app.exceptions.sql_exceptions import (NotFoundException, InvalidValueException)
from fga.frameworks.flask.core import BeforeRequestFlow
tasks_bp = flask.Blueprint('task', __name__, url_prefix='/task')
@tasks_bp.route('', methods=['GET'])
def new_or_list():
logging.info("++++++++++++++++++TEST CRON++++++++++++++++++")
return flask.Response(
response="Cron ejecutado correctamente",
status=201
)
所以我在localhost上运行我的服务器,然后我进入了模拟gCloud环境的Development SDK页面 . 在Cron Jobs部分中,我的任务出现,并且还有倒计时执行它,但是当计数变为0时,则不执行任务 .
只有当我按下“立即运行”按钮时它才会被执行,它会在我的控制台中显示所需的调试消息 . 为什么?
手动执行cron任务,因为我单击了 Run Now 按钮
1 回答
开发服务器不运行cron作业 . 这是一个很长时间缺少的功能 .