简体   繁体   English

如何通过 PHP App Engine 应用程序在 Google Compute Engine 实例上创建 cron 作业?

[英]How to create a cron job on a Google Compute Engine instance via a PHP App Engine application?

Due to the architecture of our App Engine application we can't use the App Engine cron service that Google provides and are looking for alternative options.由于 App Engine 应用程序的架构,我们无法使用 Google 提供的 App Engine cron 服务,并且正在寻找替代选项。

One possible solution we have come up with is to allow our App Engine PHP application to automatically create a cronjob on a compute engine instance.我们提出的一种可能的解决方案是允许我们的 App Engine PHP 应用程序在计算引擎实例上自动创建一个 cronjob。 This instance would simply be a utility machine which would handle nothing but the cron jobs.这个实例只是一个实用机器,它只能处理 cron 作业。

How would we create the crons in compute engine from within the App Engine application using PHP?我们如何使用 PHP 从 App Engine 应用程序中创建计算引擎中的 cron?

Because your google cloud instances can go down or up at any minute, (And also, you may have multiple instances of the same app running), which would make cron unreliable as it may trigger multiple times across multiple machines, google has created Task Scheduling, which is available on Google Compute Engine.因为你的谷歌云实例可以随时关闭或启动,(而且,你可能有同一个应用程序运行的多个实例),这会使 cron 不可靠,因为它可能会在多台机器上多次触发,谷歌创建了任务调度,可在 Google Compute Engine 上使用。

A great tutorial can be found here , and a sample can be found here .一个很棒的教程可以在这里找到,一个示例可以在这里找到。

For a PHP specific implementation of pub/sub, see this link .有关 pub/sub 的 PHP 特定实现,请参阅此链接

I don't use PHP, but it may help the reader to know you can just do我不使用 PHP,但它可以帮助读者知道你可以做

sudo crontab -e

on an Ubuntu 16 GCloud Compute Engine instance like on a normal Linux box在 Ubuntu 16 GCloud Compute Engine实例上,就像在普通 Linux 机器上一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM