简体   繁体   中英

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.

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. This instance would simply be a utility machine which would handle nothing but the cron jobs.

How would we create the crons in compute engine from within the App Engine application using PHP?

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.

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 .

I don't use PHP, but it may help the reader to know you can just do

sudo crontab -e

on an Ubuntu 16 GCloud Compute Engine instance like on a normal Linux box

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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